Class StringValueHandler
java.lang.Object
org.tquadrat.foundation.config.cli.CmdLineValueHandler<String>
org.tquadrat.foundation.config.cli.StringValueHandler
@ClassVersion(sourceVersion="$Id: StringValueHandler.java 896 2021-04-05 20:25:33Z tquadrat $")
@API(status=INTERNAL,
since="0.0.1")
public final class StringValueHandler
extends CmdLineValueHandler<String>
An implementation of
CmdLineValueHandler
for
String
values.
The value can be validated against a regular expression that is
provided via
CLIDefinition.format().
- Author:
- Kohsuke Kawaguchi (kk@kohsuke.org)
- Modified by:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: StringValueHandler.java 896 2021-04-05 20:25:33Z tquadrat $
- Since:
- 0.0.1
- See Also:
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.cli.StringValueHandler"
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe error message that indicates a failed validation: "Validation failed for \'%1$s\'".static final intThe resource bundle key for the message that indicates that the validation for the command line value had failed.Fields inherited from class org.tquadrat.foundation.config.cli.CmdLineValueHandler
DEFAULT_PROPERTY_NAME, MSG_InvalidParameter, MSGKEY_InvalidParameter -
Constructor Summary
ConstructorsConstructorDescriptionStringValueHandler(BiConsumer<String, String> valueSetter) Creates a newStringValueHandlerinstance.StringValueHandler(CLIDefinition context, BiConsumer<String, String> valueSetter) Creates a newStringValueHandlerinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<String> 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
-
MSG_ValidationFailed
The error message that indicates a failed validation: "Validation failed for \'%1$s\'".- See Also:
-
MSGKEY_ValidationFailed
The resource bundle key for the message that indicates that the validation for the command line value had failed.- See Also:
-
-
Constructor Details
-
StringValueHandler
Creates a newStringValueHandlerinstance.- Parameters:
context- The CLI definition that provides the context for this value handler.valueSetter- The function that places the translated value to the property.
-
StringValueHandler
Creates a newStringValueHandlerinstance.- Parameters:
valueSetter- The function that 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<String>- 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.
-
