Class CombinedExtendedEnum<T extends Named>

  • Type Parameters:
    T - the type of the enum

    public final class CombinedExtendedEnum<T extends Named>
    extends 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 Detail

      • of

        public static <R extends NamedCombinedExtendedEnum<R> of​(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 Optional<T> find​(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​(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:
        IllegalArgumentException - if the name is not found