Class Index<K,V>
java.lang.Object
net.kyori.adventure.util.Index<K,V>
- Type Parameters:
K- the key typeV- the value type
A bidirectional map in which keys and values must be unique.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionCreates an index map.Creates an index map.static <K,V> Index <K, V> Creates an index map.static <K,V> Index <K, V> Creates an index map.@Nullable KGets the key for a value.@Nullable KGets a key by its value or returns a fallback key.keyOrThrow(V value) Gets the key for a value or throws an exception.keys()Gets the keys.Get an unmodifiable mapping of index entries from key to value.@Nullable VGets a value by its key.@Nullable VGets a value by its key or returns a fallback value.valueOrThrow(K key) Gets a value by its key.values()Gets the keys.Get an unmodifiable mapping of index entries from value to key.
-
Method Details
-
create
-
create
@SafeVarargs public static <K, V extends Enum<V>> Index<K,V> create(Class<V> type, Function<? super V, ? extends K> keyFunction, V... values) Creates an index map.- Type Parameters:
K- the key typeV- the value type- Parameters:
type- the value typekeyFunction- the key functionvalues- the values- Returns:
- the key map
- Since:
- 4.0.0
-
create
@SafeVarargs public static <K,V> Index<K,V> create(Function<? super V, ? extends K> keyFunction, V... values) Creates an index map.- Type Parameters:
K- the key typeV- the value type- Parameters:
keyFunction- the key functionvalues- the values- Returns:
- the key map
- Since:
- 4.0.0
-
create
-
keys
-
key
-
keyOrThrow
Gets the key for a value or throws an exception.- Parameters:
value- the value- Returns:
- the key
- Throws:
NoSuchElementException- if there is no key for the value- Since:
- 4.11.0
-
keyOr
-
values
-
value
-
valueOrThrow
Gets a value by its key.- Parameters:
key- the key- Returns:
- the value
- Throws:
NoSuchElementException- if there is no value for the key- Since:
- 4.11.0
-
valueOr
-
keyToValue
-
valueToKey
-