Class CombinedExtendedEnum<T extends Named>

  • Type Parameters:
    T - the type of the enum

    public final class CombinedExtendedEnum<T extends Named>
    extends java.lang.Object
    Combines multiple extended enums into one lookup.

    Each ExtendedEnum is kept separate to ensure fast lookup of the common case. This class uses a configuration file to determine the extended enums to combine.

    It is intended that this class is used as a helper class to load the configuration and manage the map of names to instances. It should be created and used by the author of the main abstract extended enum class, and not be application developers.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<T> find​(java.lang.String name)
      Finds an instance by name.
      T lookup​(java.lang.String name)
      Looks up an instance by name.
      static <R extends Named>
      CombinedExtendedEnum<R>
      of​(java.lang.Class<R> type)
      Obtains a combined extended enum instance.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • of

        public static <R extends NamedCombinedExtendedEnum<R> of​(java.lang.Class<R> type)
        Obtains a combined extended enum instance.

        Calling this method loads configuration files to determine which extended enums to combine. The configuration file has the same simple name as the specified type and is a INI file with the suffix '.ini'.

        Type Parameters:
        R - the type of the enum
        Parameters:
        type - the type to load
        Returns:
        the extended enum
      • find

        public java.util.Optional<T> find​(java.lang.String name)
        Finds an instance by name.

        This finds the instance matching the specified name. Instances may have alternate names (aliases), thus the returned instance may have a name other than that requested.

        Parameters:
        name - the enum name to return
        Returns:
        the named enum
      • lookup

        public T lookup​(java.lang.String name)
        Looks up an instance by name.

        This finds the instance matching the specified name. Instances may have alternate names (aliases), thus the returned instance may have a name other than that requested.

        Parameters:
        name - the enum name to return
        Returns:
        the named enum
        Throws:
        java.lang.IllegalArgumentException - if the name is not found
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object