Package com.couchbase.client.core.util
Class EnumLookupTable<E extends Enum<E>>
java.lang.Object
com.couchbase.client.core.util.EnumLookupTable<E>
Provides efficient lookup for enums whose values are associated with small integers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends Enum<E>>
EnumLookupTable<E>getOrDefault
(int index, E defaultValue) Returns the enum value associated with the given integer, or the default value if not found.
-
Method Details
-
create
public static <E extends Enum<E>> EnumLookupTable<E> create(Class<E> enumClass, Function<E, Integer> enumToIndex) - Parameters:
enumToIndex
- given an enum value, returns the integer associated with the value.
-
getOrDefault
Returns the enum value associated with the given integer, or the default value if not found.- Parameters:
index
- the integer associated with the enum value to return
-