Class EnumLookupTable<E extends Enum<E>>


  • @Internal
    public class EnumLookupTable<E extends Enum<E>>
    extends Object
    Provides efficient lookup for enums whose values are associated with small integers.
    • Method Detail

      • 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