Package joptsimple.util
Class EnumConverter<E extends java.lang.Enum<E>>
- java.lang.Object
-
- joptsimple.util.EnumConverter<E>
-
- All Implemented Interfaces:
ValueConverter<E>
public abstract class EnumConverter<E extends java.lang.Enum<E>> extends java.lang.Object implements ValueConverter<E>
Converts values toEnums.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<E>clazzprivate java.lang.Stringdelimiters
-
Constructor Summary
Constructors Modifier Constructor Description protectedEnumConverter(java.lang.Class<E> clazz)This constructor must be called by subclasses, providing the enum class as the parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Econvert(java.lang.String value)Converts the given string value into a Java type.private java.lang.Stringmessage(java.lang.String value)voidsetDelimiters(java.lang.String delimiters)Sets the delimiters for the message string.java.lang.StringvaluePattern()Gives a string that describes the pattern of the values this converter expects, if any.java.lang.Class<E>valueType()Gives the class of the type of values this converter converts to.
-
-
-
Constructor Detail
-
EnumConverter
protected EnumConverter(java.lang.Class<E> clazz)
This constructor must be called by subclasses, providing the enum class as the parameter.- Parameters:
clazz- enum class
-
-
Method Detail
-
convert
public E convert(java.lang.String value)
Description copied from interface:ValueConverterConverts the given string value into a Java type.- Specified by:
convertin interfaceValueConverter<E extends java.lang.Enum<E>>- Parameters:
value- the string to convert- Returns:
- the converted value
-
valueType
public java.lang.Class<E> valueType()
Description copied from interface:ValueConverterGives the class of the type of values this converter converts to.- Specified by:
valueTypein interfaceValueConverter<E extends java.lang.Enum<E>>- Returns:
- the target class for conversion
-
setDelimiters
public void setDelimiters(java.lang.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 java.lang.String valuePattern()
Description copied from interface:ValueConverterGives a string that describes the pattern of the values this converter expects, if any. For example, a date converter can respond with adate format string.- Specified by:
valuePatternin interfaceValueConverter<E extends java.lang.Enum<E>>- Returns:
- a value pattern, or
nullif there's nothing interesting here
-
message
private java.lang.String message(java.lang.String value)
-
-