Package net.kyori.adventure.util
Class Index<K,V>
java.lang.Object
net.kyori.adventure.util.Index<K,V>
- Type Parameters:
- K- the key type
- V- the value type
public final class Index<K,V> extends Object
A bi-directional map in which keys and values must be unique.
- Since:
- 4.0.0
- 
Method SummaryModifier and Type Method Description static <K, V> @NonNull Index<K,V>create(@NonNull Function<? super V,? extends K> keyFunction, @NonNull List<V> constants)Creates an index map.static <K, V> @NonNull Index<K,V>create(@NonNull Function<? super V,? extends K> keyFunction, @NonNull V @NonNull ... values)Creates an index map.static <K, V extends Enum<V>>
 @NonNull Index<K,V>create(Class<V> type, @NonNull Function<? super V,? extends K> keyFunction)Creates an index map.static <K, V extends Enum<V>>
 @NonNull Index<K,V>create(Class<V> type, @NonNull Function<? super V,? extends K> keyFunction, @NonNull V @NonNull ... values)Creates an index map.@Nullable Kkey(@NonNull V value)Gets the key for a value.@NonNull Set<K>keys()Gets the keys.@Nullable Vvalue(@NonNull K key)Gets a value by its key.@NonNull Set<V>values()Gets the keys.
- 
Method Details- 
createpublic static <K, V extends Enum<V>> @NonNull Index<K,V> create(Class<V> type, @NonNull Function<? super V,? extends K> keyFunction)Creates an index map.- Type Parameters:
- K- the key type
- V- the value type
- Parameters:
- type- the value type
- keyFunction- the key function
- Returns:
- the key map
- Since:
- 4.0.0
 
- 
create@SafeVarargs public static <K, V extends Enum<V>> @NonNull Index<K,V> create(Class<V> type, @NonNull Function<? super V,? extends K> keyFunction, @NonNull V @NonNull ... values)Creates an index map.- Type Parameters:
- K- the key type
- V- the value type
- Parameters:
- type- the value type
- keyFunction- the key function
- values- the values
- Returns:
- the key map
- Since:
- 4.0.0
 
- 
create@SafeVarargs public static <K, V> @NonNull Index<K,V> create(@NonNull Function<? super V,? extends K> keyFunction, @NonNull V @NonNull ... values)Creates an index map.- Type Parameters:
- K- the key type
- V- the value type
- Parameters:
- keyFunction- the key function
- values- the values
- Returns:
- the key map
- Since:
- 4.0.0
 
- 
createpublic static <K, V> @NonNull Index<K,V> create(@NonNull Function<? super V,? extends K> keyFunction, @NonNull List<V> constants)Creates an index map.- Type Parameters:
- K- the key type
- V- the value type
- Parameters:
- keyFunction- the key function
- constants- the constants
- Returns:
- the key map
- Since:
- 4.0.0
 
- 
keysGets the keys.- Returns:
- the keys
- Since:
- 4.0.0
 
- 
keyGets the key for a value.- Parameters:
- value- the value
- Returns:
- the key
- Since:
- 4.0.0
 
- 
valuesGets the keys.- Returns:
- the keys
- Since:
- 4.0.0
 
- 
valueGets a value by its key.- Parameters:
- key- the key
- Returns:
- the value
- Since:
- 4.0.0
 
 
-