Config: Make it Comparable
This will be used for future sorting. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
6d2960b853
commit
76eb65d7d5
@ -5,6 +5,7 @@ import android.databinding.Bindable;
|
|||||||
import android.databinding.Observable;
|
import android.databinding.Observable;
|
||||||
import android.databinding.ObservableArrayList;
|
import android.databinding.ObservableArrayList;
|
||||||
import android.databinding.ObservableList;
|
import android.databinding.ObservableList;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.wireguard.android.BR;
|
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.
|
* 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 final Pattern PATTERN = Pattern.compile("^[a-zA-Z0-9_=+.-]{1,16}$");
|
||||||
|
|
||||||
private static boolean isNameValid(final String name) {
|
private static boolean isNameValid(final String name) {
|
||||||
@ -31,6 +33,11 @@ public class Config extends BaseObservable implements Copyable<Config>, Observab
|
|||||||
private String name;
|
private String name;
|
||||||
private final ObservableList<Peer> peers = new ObservableArrayList<>();
|
private final ObservableList<Peer> peers = new ObservableArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NonNull final Config config) {
|
||||||
|
return getName().compareTo(config.getName());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Config copy() {
|
public Config copy() {
|
||||||
final Config copy = new Config();
|
final Config copy = new Config();
|
||||||
|
Loading…
Reference in New Issue
Block a user