diff options
author | Samuel Holland <samuel@sholland.org> | 2017-08-16 01:06:05 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2017-08-16 01:06:05 -0500 |
commit | 942b4d30c24e201fea9d0444923fc7a4c344b83d (patch) | |
tree | 8bc36aadfc39db7323d6abd49067e600e4b84e64 /app/src/main/java/com | |
parent | 76c958ae7a3b2e7c6edb00ff301b0c67e04c01de (diff) |
Config: Make it Comparable
This will be used for future sorting.
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r-- | app/src/main/java/com/wireguard/config/Config.java | 9 |
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); |