Class EnumValueHandler<T extends Enum<T>>
java.lang.Object
org.tquadrat.foundation.config.cli.CmdLineValueHandler<T>
org.tquadrat.foundation.config.cli.EnumValueHandler<T>
- Type Parameters:
T- The concrete data type that is handled by this value handler implementation.
@ClassVersion(sourceVersion="$Id: EnumValueHandler.java 1061 2023-09-25 16:32:43Z tquadrat $")
@API(status=STABLE,
since="0.0.1")
public final class EnumValueHandler<T extends Enum<T>>
extends CmdLineValueHandler<T>
An implementation of
CmdLineValueHandler
for types that are derived from
Enum.- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: EnumValueHandler.java 1061 2023-09-25 16:32:43Z tquadrat $
- Since:
- 0.0.1
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.cli.EnumValueHandler"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EnumStringConverter<T> The implementation ofStringConverterthat is used to translate the String value from the command line into the desired object instance.static final StringThe error message for the name of an unknownenumvalue on the command line: "Unknown/invalid value: %1$s".static final intThe resource bundle key for the message about the name for an unknownenumvalue on the command line.Fields inherited from class org.tquadrat.foundation.config.cli.CmdLineValueHandler
DEFAULT_PROPERTY_NAME, MSG_InvalidParameter, MSGKEY_InvalidParameter -
Constructor Summary
ConstructorsConstructorDescriptionEnumValueHandler(Class<T> enumType, BiConsumer<String, T> valueSetter) Creates a newEnumValueHandlerinstance.EnumValueHandler(CLIDefinition context, Class<T> enumType, BiConsumer<String, T> valueSetter) Creates a newEnumValueHandlerinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final Collection<T> translate(Parameters params) Translates the command line values that can be referenced via theparamsargument to the target type.Methods inherited from class org.tquadrat.foundation.config.cli.CmdLineValueHandler
getCLIDefinition, getPropertyName, getValueSetter, parseCmdLine, setContext
-
Field Details
-
m_StringConverter
The implementation ofStringConverterthat is used to translate the String value from the command line into the desired object instance. -
MSG_UnknownValue
The error message for the name of an unknownenumvalue on the command line: "Unknown/invalid value: %1$s".- See Also:
-
MSGKEY_UnknownValue
The resource bundle key for the message about the name for an unknownenumvalue on the command line.- See Also:
-
-
Constructor Details
-
EnumValueHandler
Creates a newEnumValueHandlerinstance.- Parameters:
enumType- The data type for the property.valueSetter- TheConsumerthat places the translated value to the property.
-
EnumValueHandler
Creates a newEnumValueHandlerinstance.- Parameters:
context- The CLI definition that provides the context for this value handler.enumType- The data type for the property.valueSetter- TheConsumerthat places the translated value to the property.
-
-
Method Details
-
translate
Translates the command line values that can be referenced via theparamsargument to the target type.- Specified by:
translatein classCmdLineValueHandler<T extends Enum<T>>- Parameters:
params- The command line values to translate.- Returns:
- A collection with the result; each entry in the collection corresponds to one value from the command line.
- Throws:
CmdLineException- The given parameters cannot be parsed to the target type.
-
