Class EnumLookup


  • public final class EnumLookup
    extends java.lang.Object
    Utility class to cache more flexible enum lookup.

    While normally case and punctuation have to match exactly, this method performs lookup that:

    • is case-insensitive
    • ignores underscores
    • caches mappings

    If the enum has two fields that are equal except for case and underscores, an exact match will return the appropriate value, and any fuzzy matches will map to the first value in the enum that is applicable.

    Since:
    4.0.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends java.lang.Enum<T>>
      @Nullable T
      lookupEnum​(java.lang.Class<T> clazz, java.lang.String key)
      Perform a fuzzy lookup of key in enum clazz.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • lookupEnum

        public static <T extends java.lang.Enum<T>> @Nullable T lookupEnum​(java.lang.Class<T> clazz,
                                                                           java.lang.String key)
        Perform a fuzzy lookup of key in enum clazz.
        Type Parameters:
        T - type of value
        Parameters:
        clazz - class to find key in
        key - key to find
        Returns:
        optionally the enum
        Since:
        4.0.0