Replaced String.join with implementation in Utils class for Android compatibility.

Bumped version to 0.2.4.
This commit is contained in:
ChronosX88 2019-05-10 19:04:11 +04:00
parent 61255b3521
commit 63667b50db
3 changed files with 28 additions and 4 deletions

View File

@ -4,7 +4,7 @@ plugins {
}
group 'io.github.chronosx88'
version '0.2.3'
version '0.2.4'
sourceCompatibility = 1.8

View File

@ -97,10 +97,10 @@ public class PathRef {
}
public void on(NodeChangeListener changeListener) {
dispatcher.addChangeListener(String.join("/", path), changeListener);
dispatcher.addChangeListener(Utils.join("/", path), changeListener);
}
public void map(NodeChangeListener.ForEach forEachListener) {
dispatcher.addForEachChangeListener(String.join("/", path), forEachListener);
dispatcher.addForEachChangeListener(Utils.join("/", path), forEachListener);
}
}

View File

@ -5,6 +5,7 @@ import io.github.chronosx88.JGUN.storageBackends.StorageBackend;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.ConcurrentSkipListSet;
public class Utils {
@ -76,7 +77,7 @@ public class Utils {
if(value instanceof JSONObject) {
path.add(key);
String soul = "";
soul = String.join("/", path);
soul = Utils.join("/", path);
Node tmpNode = Utils.newNode(soul, (JSONObject) value);
node.values.remove(key);
node.values.put(key, new JSONObject().put("#", soul));
@ -119,4 +120,27 @@ public class Utils {
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();
}
}