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"

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

UML Diagram for "org.tquadrat.foundation.config.cli.EnumValueHandler"
  • Field Details

  • Constructor Details

    • EnumValueHandler

      public EnumValueHandler(Class<T> enumType, BiConsumer<String,T> valueSetter)
      Creates a new EnumValueHandler instance.
      Parameters:
      enumType - The data type for the property.
      valueSetter - The Consumer that places the translated value to the property.
    • EnumValueHandler

      public EnumValueHandler(CLIDefinition context, Class<T> enumType, BiConsumer<String,T> valueSetter)
      Creates a new EnumValueHandler instance.
      Parameters:
      context - The CLI definition that provides the context for this value handler.
      enumType - The data type for the property.
      valueSetter - The Consumer that places the translated value to the property.
  • Method Details

    • translate

      protected final Collection<T> 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<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.