aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-02-10 17:02:29 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-02-10 17:04:34 +0100
commit5d9cc7a1739296f7bc379be99527460eca7a95d5 (patch)
tree69e9ef44701283394f2553d63460e04a14979fdb
parentInetAddresses: don't have global android import (diff)
downloadwireguard-android-5d9cc7a1739296f7bc379be99527460eca7a95d5.tar.xz
wireguard-android-5d9cc7a1739296f7bc379be99527460eca7a95d5.zip
Attribute: remove need for android TextUtils
If this is to be JRE-only, then it doesn't make sense to rely on the android class, especially since this is so trivial to inline.
-rw-r--r--app/src/main/java/com/wireguard/config/Attribute.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/src/main/java/com/wireguard/config/Attribute.java b/app/src/main/java/com/wireguard/config/Attribute.java
index 375acc4..1e9e25f 100644
--- a/app/src/main/java/com/wireguard/config/Attribute.java
+++ b/app/src/main/java/com/wireguard/config/Attribute.java
@@ -5,8 +5,7 @@
package com.wireguard.config;
-import android.text.TextUtils;
-
+import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -25,7 +24,17 @@ public final class Attribute {
}
public static String join(final Iterable<?> values) {
- return TextUtils.join(", ", values);
+ final Iterator<?> it = values.iterator();
+ if (!it.hasNext()) {
+ return "";
+ }
+ final StringBuilder sb = new StringBuilder();
+ sb.append(it.next());
+ while (it.hasNext()) {
+ sb.append(", ");
+ sb.append(it.next());
+ }
+ return sb.toString();
}
public static Optional<Attribute> parse(final CharSequence line) {