Class EnumConverter<E extends Enum<E>>

java.lang.Object
joptsimple.util.EnumConverter<E>
All Implemented Interfaces:
ValueConverter<E>

public abstract class EnumConverter<E extends Enum<E>> extends Object implements ValueConverter<E>
Converts values to Enums.
  • Field Details

    • clazz

      private final Class<E extends Enum<E>> clazz
    • delimiters

      private String delimiters
  • Constructor Details

    • EnumConverter

      protected EnumConverter(Class<E> clazz)
      This constructor must be called by subclasses, providing the enum class as the parameter.
      Parameters:
      clazz - enum class
  • Method Details

    • convert

      public E convert(String value)
      Description copied from interface: ValueConverter
      Converts the given string value into a Java type.
      Specified by:
      convert in interface ValueConverter<E extends Enum<E>>
      Parameters:
      value - the string to convert
      Returns:
      the converted value
    • valueType

      public Class<E> valueType()
      Description copied from interface: ValueConverter
      Gives the class of the type of values this converter converts to.
      Specified by:
      valueType in interface ValueConverter<E extends Enum<E>>
      Returns:
      the target class for conversion
    • setDelimiters

      public void setDelimiters(String delimiters)
      Sets the delimiters for the message string. Must be a 3-letter string, where the first character is the prefix, the second character is the delimiter between the values, and the 3rd character is the suffix.
      Parameters:
      delimiters - delimiters for message string. Default is [,]
    • valuePattern

      public String valuePattern()
      Description copied from interface: ValueConverter
      Gives a string that describes the pattern of the values this converter expects, if any. For example, a date converter can respond with a date format string.
      Specified by:
      valuePattern in interface ValueConverter<E extends Enum<E>>
      Returns:
      a value pattern, or null if there's nothing interesting here
    • message

      private String message(String value)