summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-16 01:06:05 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-16 01:06:05 -0500
commit76eb65d7d5d15ff38823939db4979eb5c1f3bd24 (patch)
tree8bc36aadfc39db7323d6abd49067e600e4b84e64 /app/src/main/java/com
parent6d2960b8537f67d7b4051cb244500fbe3f0bcd7e (diff)
Config: Make it Comparable
This will be used for future sorting. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r--app/src/main/java/com/wireguard/config/Config.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/src/main/java/com/wireguard/config/Config.java b/app/src/main/java/com/wireguard/config/Config.java
index 414b4894..e39832ba 100644
--- a/app/src/main/java/com/wireguard/config/Config.java
+++ b/app/src/main/java/com/wireguard/config/Config.java
@@ -5,6 +5,7 @@ import android.databinding.Bindable;
import android.databinding.Observable;
import android.databinding.ObservableArrayList;
import android.databinding.ObservableList;
+import android.support.annotation.NonNull;
import com.wireguard.android.BR;
@@ -19,7 +20,8 @@ import java.util.regex.Pattern;
* Represents a wg-quick configuration file, its name, and its connection state.
*/
-public class Config extends BaseObservable implements Copyable<Config>, Observable {
+public class Config extends BaseObservable
+ implements Comparable<Config>, Copyable<Config>, Observable {
private static final Pattern PATTERN = Pattern.compile("^[a-zA-Z0-9_=+.-]{1,16}$");
private static boolean isNameValid(final String name) {
@@ -32,6 +34,11 @@ public class Config extends BaseObservable implements Copyable<Config>, Observab
private final ObservableList<Peer> peers = new ObservableArrayList<>();
@Override
+ public int compareTo(@NonNull final Config config) {
+ return getName().compareTo(config.getName());
+ }
+
+ @Override
public Config copy() {
final Config copy = new Config();
copy.copyFrom(this);