@Component public class StaticFieldConverterImpl extends Object implements StaticFieldConverter
Converter
for those classes which provide public static fields to represent possible textual values.TAB_COMPLETION_COUNT_PREFIX
Constructor and Description |
---|
StaticFieldConverterImpl() |
Modifier and Type | Method and Description |
---|---|
void |
add(Class<?> clazz) |
Object |
convertFromText(String value,
Class<?> requiredType,
String optionContext)
Converts from the given String value to type T
|
boolean |
getAllPossibleValues(List<Completion> completions,
Class<?> requiredType,
String existingData,
String optionContext,
MethodTarget target)
Populates the given list with the possible completions
|
void |
remove(Class<?> clazz) |
boolean |
supports(Class<?> requiredType,
String optionContext)
Indicates whether this converter supports the given type in the given option context
|
public void add(Class<?> clazz)
add
in interface StaticFieldConverter
public void remove(Class<?> clazz)
remove
in interface StaticFieldConverter
public Object convertFromText(String value, Class<?> requiredType, String optionContext)
Converter
convertFromText
in interface Converter<Object>
value
- the value to convertrequiredType
- the type being converted to; can't be null
optionContext
- a non-null
string that customises the behaviour of this converter for a given
CliOption
of a given CliCommand
; the contents will have special meaning to this converter (e.g.
be a comma-separated list of keywords known to this converter)public boolean getAllPossibleValues(List<Completion> completions, Class<?> requiredType, String existingData, String optionContext, MethodTarget target)
Converter
getAllPossibleValues
in interface Converter<Object>
completions
- the list to populate; can't be null
requiredType
- the type of parameter for which a string is being enteredexistingData
- what the user has typed so faroptionContext
- a non-null
string that customises the behaviour of this converter for a given
CliOption
of a given CliCommand
; the contents will have special meaning to this converter (e.g.
be a comma-separated list of keywords known to this converter)true
if all the added completions are complete values, or false
if the user can
press TAB to add further information to some or all of thempublic boolean supports(Class<?> requiredType, String optionContext)
Converter
supports
in interface Converter<Object>
requiredType
- the type being checkedoptionContext
- a non-null
string that customises the behaviour of this converter for a given
CliOption
of a given CliCommand
; the contents will have special meaning to this converter (e.g.
be a comma-separated list of keywords known to this converter)