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"

UML Diagram for "org.tquadrat.foundation.config.cli.DateValueHandler"

UML Diagram for "org.tquadrat.foundation.config.cli.DateValueHandler"
  • Constructor Details

    • DateValueHandler

      public DateValueHandler(CLIDefinition context, BiConsumer<String,Date> valueSetter)
      Creates a new DateValueHandler 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

      public DateValueHandler(BiConsumer<String,Date> valueSetter)
      Creates a new DateValueHandler instance.
      Parameters:
      valueSetter - The function that places the translated value to the property.
  • Method Details

    • getFormat

      private final String getFormat()
      Retrieves the format that was given with the annotation; if that is empty or null, 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

      protected final Collection<Date> translate(Parameters params) throws CmdLineException
      Translates the command line values that can be referenced via the params argument to the target type.
      Specified by:
      translate in class CmdLineValueHandler<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.