diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2020-03-09 19:06:11 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2020-03-09 19:24:27 +0530 |
commit | 7d48bef70a56d4370856eedab619b1f83ac3d0d0 (patch) | |
tree | 76fd859578e499cd3a8fd2f402652530ea36a72d /ui/src/main/java/com/wireguard/util | |
parent | 6bc3e257f80a273d35d07099bd4ed99eb45163bf (diff) |
Rename app module to ui
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java/com/wireguard/util')
-rw-r--r-- | ui/src/main/java/com/wireguard/util/Keyed.java | 14 | ||||
-rw-r--r-- | ui/src/main/java/com/wireguard/util/KeyedList.java | 32 | ||||
-rw-r--r-- | ui/src/main/java/com/wireguard/util/SortedKeyedList.java | 31 |
3 files changed, 77 insertions, 0 deletions
diff --git a/ui/src/main/java/com/wireguard/util/Keyed.java b/ui/src/main/java/com/wireguard/util/Keyed.java new file mode 100644 index 00000000..f31a43a2 --- /dev/null +++ b/ui/src/main/java/com/wireguard/util/Keyed.java @@ -0,0 +1,14 @@ +/* + * Copyright © 2017-2019 WireGuard LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.wireguard.util; + +/** + * Interface for objects that have a identifying key of the given type. + */ + +public interface Keyed<K> { + K getKey(); +} diff --git a/ui/src/main/java/com/wireguard/util/KeyedList.java b/ui/src/main/java/com/wireguard/util/KeyedList.java new file mode 100644 index 00000000..c116c1da --- /dev/null +++ b/ui/src/main/java/com/wireguard/util/KeyedList.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2017-2019 WireGuard LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.wireguard.util; + +import androidx.annotation.Nullable; + +import java.util.Collection; +import java.util.List; + +/** + * A list containing elements that can be looked up by key. A {@code KeyedList} cannot contain + * {@code null} elements. + */ + +public interface KeyedList<K, E extends Keyed<? extends K>> extends List<E> { + boolean containsAllKeys(Collection<K> keys); + + boolean containsKey(K key); + + @Nullable + E get(K key); + + @Nullable + E getLast(K key); + + int indexOfKey(K key); + + int lastIndexOfKey(K key); +} diff --git a/ui/src/main/java/com/wireguard/util/SortedKeyedList.java b/ui/src/main/java/com/wireguard/util/SortedKeyedList.java new file mode 100644 index 00000000..b144fc85 --- /dev/null +++ b/ui/src/main/java/com/wireguard/util/SortedKeyedList.java @@ -0,0 +1,31 @@ +/* + * Copyright © 2017-2019 WireGuard LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.wireguard.util; + +import androidx.annotation.Nullable; + +import java.util.Collection; +import java.util.Comparator; +import java.util.Set; + +/** + * A keyed list where all elements are sorted by the comparator returned by {@code comparator()} + * applied to their keys. + */ + +public interface SortedKeyedList<K, E extends Keyed<? extends K>> extends KeyedList<K, E> { + Comparator<? super K> comparator(); + + @Nullable + K firstKey(); + + Set<K> keySet(); + + @Nullable + K lastKey(); + + Collection<E> values(); +} |