Package org.goplanit.utils.enums
Interface EnumOf<T extends EnumValue<V>,V>
-
- Type Parameters:
T
- enum typeV
- internal value type of enum
- All Known Implementing Classes:
RouteType
,StopLocationType
public interface EnumOf<T extends EnumValue<V>,V>
Interface that deals with injecting way to create an enum based on its internal enum value through EnumValue, e.g. and enum can implement this interface and EnumValue, then callcreateFromValues(Supplier, Object)
where the supplier is its values() method and the value is some value that is attached to the enum instance. It will then find that matching instance and return it.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default <T> T
createFromValues(Supplier<T[]> enumValuesSupplier, V value)
Create an enum instance from a list of options based on its internal value
-
-
-
Method Detail
-
createFromValues
default <T> T createFromValues(Supplier<T[]> enumValuesSupplier, V value)
Create an enum instance from a list of options based on its internal value- Type Parameters:
T
- type of the supplier- Parameters:
enumValuesSupplier
- the supplier to usevalue
- internal value to extract enum for- Returns:
- the corresponding enum found, null when not present
-
-