Package ubic.gemma.cli.util
Class EnumConverter<T extends Enum<T>>
- java.lang.Object
-
- ubic.gemma.cli.util.EnumConverter<T>
-
- All Implemented Interfaces:
org.apache.commons.cli.Converter<T,IllegalArgumentException>
,EnumeratedConverter<T,IllegalArgumentException>
public class EnumConverter<T extends Enum<T>> extends Object implements EnumeratedConverter<T,IllegalArgumentException>
ConvertEnum
to string.This converter accepts both snake-case and kebab-case strings. It will first attempt to match the string as-is, then it will perform an upper case match.
- Author:
- poirigui
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
apply(String value)
Map<String,org.springframework.context.MessageSourceResolvable>
getPossibleValues()
Obtain a list of possible values that the converter can convert toEnumeratedConverter
.static <T extends Enum<T>>
EnumConverter<T>of(Class<T> enumClass)
static <T extends Enum<T>>
EnumConverter<T>of(Class<T> enumClass, EnumMap<T,org.springframework.context.MessageSourceResolvable> descriptions)
-
-
-
Method Detail
-
of
public static <T extends Enum<T>> EnumConverter<T> of(Class<T> enumClass)
-
of
public static <T extends Enum<T>> EnumConverter<T> of(Class<T> enumClass, EnumMap<T,org.springframework.context.MessageSourceResolvable> descriptions)
-
apply
public T apply(String value)
- Specified by:
apply
in interfaceorg.apache.commons.cli.Converter<T extends Enum<T>,IllegalArgumentException>
-
getPossibleValues
public Map<String,org.springframework.context.MessageSourceResolvable> getPossibleValues()
Description copied from interface:EnumeratedConverter
Obtain a list of possible values that the converter can convert toEnumeratedConverter
.Implementation should use either a
SortedMap
orLinkedHashMap
for reproducibility.- Specified by:
getPossibleValues
in interfaceEnumeratedConverter<T extends Enum<T>,IllegalArgumentException>
-
-