mirror of
https://github.com/ChronosX88/JGUN.git
synced 2024-11-09 16:51:02 +00:00
Replaced String.join with implementation in Utils class for Android compatibility.
Bumped version to 0.2.4.
This commit is contained in:
parent
61255b3521
commit
63667b50db
@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'io.github.chronosx88'
|
group 'io.github.chronosx88'
|
||||||
version '0.2.3'
|
version '0.2.4'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
|
|
||||||
|
@ -97,10 +97,10 @@ public class PathRef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void on(NodeChangeListener changeListener) {
|
public void on(NodeChangeListener changeListener) {
|
||||||
dispatcher.addChangeListener(String.join("/", path), changeListener);
|
dispatcher.addChangeListener(Utils.join("/", path), changeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void map(NodeChangeListener.ForEach forEachListener) {
|
public void map(NodeChangeListener.ForEach forEachListener) {
|
||||||
dispatcher.addForEachChangeListener(String.join("/", path), forEachListener);
|
dispatcher.addForEachChangeListener(Utils.join("/", path), forEachListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import io.github.chronosx88.JGUN.storageBackends.StorageBackend;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.ConcurrentSkipListSet;
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
@ -76,7 +77,7 @@ public class Utils {
|
|||||||
if(value instanceof JSONObject) {
|
if(value instanceof JSONObject) {
|
||||||
path.add(key);
|
path.add(key);
|
||||||
String soul = "";
|
String soul = "";
|
||||||
soul = String.join("/", path);
|
soul = Utils.join("/", path);
|
||||||
Node tmpNode = Utils.newNode(soul, (JSONObject) value);
|
Node tmpNode = Utils.newNode(soul, (JSONObject) value);
|
||||||
node.values.remove(key);
|
node.values.remove(key);
|
||||||
node.values.put(key, new JSONObject().put("#", soul));
|
node.values.put(key, new JSONObject().put("#", soul));
|
||||||
@ -119,4 +120,27 @@ public class Utils {
|
|||||||
for(node)
|
for(node)
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string containing the tokens joined by delimiters.
|
||||||
|
*
|
||||||
|
* @param delimiter a CharSequence that will be inserted between the tokens. If null, the string
|
||||||
|
* "null" will be used as the delimiter.
|
||||||
|
* @param tokens an array objects to be joined. Strings will be formed from the objects by
|
||||||
|
* calling object.toString(). If tokens is null, a NullPointerException will be thrown. If
|
||||||
|
* tokens is empty, an empty string will be returned.
|
||||||
|
*/
|
||||||
|
public static String join(CharSequence delimiter, Iterable tokens) {
|
||||||
|
final Iterator<?> it = tokens.iterator();
|
||||||
|
if (!it.hasNext()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(it.next());
|
||||||
|
while (it.hasNext()) {
|
||||||
|
sb.append(delimiter);
|
||||||
|
sb.append(it.next());
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user