Class SimpleCmdLineValueHandler<T>
java.lang.Object
org.tquadrat.foundation.config.cli.CmdLineValueHandler<T>
org.tquadrat.foundation.config.cli.SimpleCmdLineValueHandler<T>
- Type Parameters:
T- The target type.
- Direct Known Subclasses:
YesNoValueHandler
@ClassVersion(sourceVersion="$Id: SimpleCmdLineValueHandler.java 1061 2023-09-25 16:32:43Z tquadrat $")
@API(status=STABLE,
since="0.1.0")
public sealed class SimpleCmdLineValueHandler<T>
extends CmdLineValueHandler<T>
permits YesNoValueHandler
The implementation of
CmdLineValueHandler
for all those types for that an implementation of
StringConverter
exists.- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: SimpleCmdLineValueHandler.java 1061 2023-09-25 16:32:43Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.cli.SimpleCmdLineValueHandler"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringConverter<? extends T> The implementation ofStringConverterthat is used to translate the String value from the command line into the desired object instance.Fields inherited from class org.tquadrat.foundation.config.cli.CmdLineValueHandler
DEFAULT_PROPERTY_NAME, MSG_InvalidParameter, MSGKEY_InvalidParameter -
Constructor Summary
ConstructorsConstructorDescriptionSimpleCmdLineValueHandler(BiConsumer<String, T> valueSetter, StringConverter<? extends T> stringConverter) Creates a newSimpleCmdLineValueHandlerinstance.SimpleCmdLineValueHandler(CLIDefinition context, BiConsumer<String, T> valueSetter, StringConverter<? extends T> stringConverter) Creates a newSimpleCmdLineValueHandlerinstance. -
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.
-
-
Constructor Details
-
SimpleCmdLineValueHandler
public SimpleCmdLineValueHandler(BiConsumer<String, T> valueSetter, StringConverter<? extends T> stringConverter) Creates a newSimpleCmdLineValueHandlerinstance.- Parameters:
valueSetter- TheConsumerthat places the translated value to the property.stringConverter- The implementation ofStringConverterthat is used to translate the String value from the command line into the desired object instance.
-
SimpleCmdLineValueHandler
public SimpleCmdLineValueHandler(CLIDefinition context, BiConsumer<String, T> valueSetter, StringConverter<? extends T> stringConverter) Creates a newSimpleCmdLineValueHandlerinstance.- Parameters:
context- The CLI definition that provides the context for this value handler.valueSetter- TheConsumerthat places the translated value to the property.stringConverter- The implementation ofStringConverterthat is used to translate the String value from the command line into the desired object instance.
-
-
Method Details
-
translate
Translates the command line values that can be referenced via theparamsargument to the target type.- Specified by:
translatein classCmdLineValueHandler<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.
-
