Class DateValueHandler
java.lang.Object
org.tquadrat.foundation.config.cli.CmdLineValueHandler<Date>
org.tquadrat.foundation.config.cli.DateValueHandler
@ClassVersion(sourceVersion="$Id: DateValueHandler.java 1061 2023-09-25 16:32:43Z tquadrat $")
@API(status=INTERNAL,
since="0.0.1")
public final class DateValueHandler
extends CmdLineValueHandler<Date>
An implementation of
CmdLineValueHandler
for
Date
values.
The method
translate(Parameters)
will use
SimpleDateFormat
to parse the given String to an instance of Date
.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: DateValueHandler.java 1061 2023-09-25 16:32:43Z tquadrat $
- Since:
- 0.0.1
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.cli.DateValueHandler"
-
Field Summary
Fields inherited from class org.tquadrat.foundation.config.cli.CmdLineValueHandler
DEFAULT_PROPERTY_NAME, MSG_InvalidParameter, MSGKEY_InvalidParameter
-
Constructor Summary
ConstructorsConstructorDescriptionDateValueHandler
(BiConsumer<String, Date> valueSetter) Creates a newDateValueHandler
instance.DateValueHandler
(CLIDefinition context, BiConsumer<String, Date> valueSetter) Creates a newDateValueHandler
instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate final String
Retrieves the format that was given with the annotation; if that is empty ornull
, the default "yyyy-MM-dd
" will be returned.
Override this method for a different default.protected final Collection
<Date> translate
(Parameters params) Translates the command line values that can be referenced via theparams
argument to the target type.Methods inherited from class org.tquadrat.foundation.config.cli.CmdLineValueHandler
getCLIDefinition, getPropertyName, getValueSetter, parseCmdLine, setContext
-
Constructor Details
-
DateValueHandler
Creates a newDateValueHandler
instance.- Parameters:
context
- The CLI definition that provides the context for this value handler.valueSetter
- The function that places the translated value to the property.
-
DateValueHandler
Creates a newDateValueHandler
instance.- Parameters:
valueSetter
- The function that places the translated value to the property.
-
-
Method Details
-
getFormat
Retrieves the format that was given with the annotation; if that is empty ornull
, the default "yyyy-MM-dd
" will be returned.
Override this method for a different default.- Returns:
- The date format to use by the parser.
-
translate
Translates the command line values that can be referenced via theparams
argument to the target type.- Specified by:
translate
in classCmdLineValueHandler<Date>
- 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.
-