Class EnumLookupTable<E extends Enum<E>>

java.lang.Object
com.couchbase.client.core.util.EnumLookupTable<E>

@Internal public class EnumLookupTable<E extends Enum<E>> extends Object
Provides efficient lookup for enums whose values are associated with small integers.
  • 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

      public E getOrDefault(int index, E defaultValue)
      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