@ComponentSpecification public interface EnumProvider extends Iterable<EnumDefinition<?,?>>
enumerations. The major goal of this component is
generic support for enumerations of any kind. This may e.g. be used for user-interfaces in radio-groups, drop-downs,
combo-boxes, or the like. More advanced cases are implementations that dynamically load the
enum values from a file, database or a service. Within mmm-util-core
you will only find simple implementations of this interface. Dynamic enumerations are provided by higher-level
components of the project.| Modifier and Type | Method and Description |
|---|---|
void |
clear(EnumDefinition<?,?> enumDefinition)
This method clears the (potentially) cached
enum values of the given
EnumDefinition. |
<TYPE> EnumDefinition<TYPE,?> |
getEnumDefinition(Class<TYPE> enumType)
This method gets the
EnumDefinition with the given enumType. |
EnumDefinition<?,?> |
getEnumDefinition(String key)
This method gets the
EnumDefinition with the given key. |
Iterator<EnumDefinition<?,?>> |
getEnumDefinitions()
This method gets an (unmodifiable)
Iterator with all existing EnumDefinitions. |
<CATEGORY,ENUM extends EnumTypeWithCategory<?,CATEGORY>> |
getEnumDefinitionWithCategory(Class<? extends ENUM> enumType)
This method gets the
EnumDefinition with the given enumType. |
<ENUM> ENUM |
getEnumValue(Class<ENUM> enumType,
String value,
boolean required)
|
<ENUM> ENUM |
getEnumValue(EnumDefinition<ENUM,?> enumDefinition,
String value,
boolean required)
|
<ENUM> List<ENUM> |
getEnumValues(EnumDefinition<ENUM,?> enumDefinition)
This method gets the
List of EnumType-instances that represent the values of the given
EnumDefinition. |
<CATEGORY,ENUM extends EnumTypeWithCategory<?,CATEGORY>> |
getEnumValues(EnumDefinition<ENUM,CATEGORY> enumDefinition,
CATEGORY... categories)
|
boolean |
isAvailable(EnumDefinition<?,?> enumDefinition)
This method determines if the given
EnumDefinition is available, so it is ensured that the
enum values can be retrieved. |
Iterator<EnumDefinition<?,?>> |
iterator()
The same as
getEnumDefinitions(). |
void |
require(EnumDefinition<?,?>... enumDefinitions)
This method triggers that the given
EnumDefinitions are available. |
void |
require(Runnable callback,
EnumDefinition<?,?>... enumDefinitions)
This method triggers that the given
EnumDefinitions are available. |
forEach, spliteratorIterator<EnumDefinition<?,?>> iterator()
getEnumDefinitions().
iterator in interface Iterable<EnumDefinition<?,?>>Iterator<EnumDefinition<?,?>> getEnumDefinitions()
Iterator with all existing EnumDefinitions. In most cases this
is a static list, however it may also be dynamic.Iterator with all existing EnumDefinitions.iterator()EnumDefinition<?,?> getEnumDefinition(String key) throws ObjectNotFoundException
EnumDefinition with the given key. To get the default EnumDefinition
for a particular enum type you should use getEnumDefinition(Class)
instead. However, for the same enum type multiple EnumDefinitions can exists. The default definition should
have the qualified name of the enum type while
additional definitions should have more specific keys that do not clash with others (e.g.
"java.lang.Boolean_All_None").key - is the key of the requested definition.EnumDefinition.ObjectNotFoundException - if no such EnumDefinition exists.<TYPE> EnumDefinition<TYPE,?> getEnumDefinition(Class<TYPE> enumType) throws ObjectNotFoundException
EnumDefinition with the given enumType.TYPE - is the generic for the enum type.enumType - is the enum type of the requested definition.EnumDefinition.ObjectNotFoundException - if no such EnumDefinition exists.<CATEGORY,ENUM extends EnumTypeWithCategory<?,CATEGORY>> EnumDefinition<ENUM,CATEGORY> getEnumDefinitionWithCategory(Class<? extends ENUM> enumType) throws ObjectNotFoundException
EnumDefinition with the given enumType.CATEGORY - is the generic for the category.ENUM - is the generic for the enum type.enumType - is the enum type of the requested definition.EnumDefinition.ObjectNotFoundException - if no such EnumDefinition exists.boolean isAvailable(EnumDefinition<?,?> enumDefinition)
EnumDefinition is available, so it is ensured that the
enum values can be retrieved.enumDefinition - is the EnumDefinition to check.true if the enum values for the given EnumDefinition
are available (already loaded / in cache), false otherwise.void require(EnumDefinition<?,?>... enumDefinitions)
EnumDefinitions are available.enumDefinitions - are the EnumDefinitions of the required enumerations.void require(Runnable callback, EnumDefinition<?,?>... enumDefinitions)
EnumDefinitions are available. In
advanced to require(EnumDefinition...) it allows to specify a callback that gets invoked after the
required EnumDefinitions are available. This is useful in asynchronous
environments (e.g. in client applications that have to receive the values (asynchronously) from the server).callback - is a Runnable that will be called after all given
EnumDefinitions are available.enumDefinitions - are the EnumDefinitions of the required enumerations.<ENUM> List<ENUM> getEnumValues(EnumDefinition<ENUM,?> enumDefinition)
List of EnumType-instances that represent the values of the given
EnumDefinition. In case the enum type implements
AttributeReadDeprecated the
deprecated enum values will be
excluded from the returned List.ENUM - is the generic for the enum type.enumDefinition - is the EnumDefinition for which the values are requested.List of EnumTypes.<ENUM> ENUM getEnumValue(EnumDefinition<ENUM,?> enumDefinition, String value, boolean required) throws IllegalCaseException
ENUM - is the generic for the enum type.enumDefinition - is the EnumDefinition for which the value is requested.value - is the string representation of the requested EnumType
instance based on EnumDefinition.getFormatter().required - - true if the requested EnumType-instance is required, false otherwise.EnumType-instance. Will be null if value is null or if required
is false and no such EnumType instance exists.IllegalCaseException - if required is true and no such EnumType instance exists.<ENUM> ENUM getEnumValue(Class<ENUM> enumType, String value, boolean required) throws IllegalCaseException
ENUM - is the generic for the enum type.enumType - is the EnumType for which the value is requested.value - is the string representation of the requested EnumType
instance based on EnumDefinition.getFormatter().required - - true if the requested EnumType-instance is required, false otherwise.EnumType-instance. Will be null if value is null or if required
is false and no such EnumType instance exists.IllegalCaseException - if required is true and no such EnumType instance exists.<CATEGORY,ENUM extends EnumTypeWithCategory<?,CATEGORY>> List<ENUM> getEnumValues(EnumDefinition<ENUM,CATEGORY> enumDefinition, CATEGORY... categories)
List of enum values filtered by the given
categories. So only these enum
values are returned that have a categoryCATEGORY - is the generic type of the category
type.ENUM - is the generic for the enum type.enumDefinition - is the EnumDefinition for which the values are requested.categories - are the categories.List of matching EnumTypes.void clear(EnumDefinition<?,?> enumDefinition)
enum values of the given
EnumDefinition. If the enum is dynamic it is NOT
available (anymore) after this operation.enumDefinition - is the EnumDefinition to clear.Copyright © 2001–2016 mmm-Team. All rights reserved.