java.lang.Object
com.github.rvesse.airline.types.DefaultTypeConverterProvider
com.github.rvesse.airline.types.DefaultTypeConverter
- All Implemented Interfaces:
TypeConverter
,TypeConverterProvider
- Direct Known Subclasses:
ExtendedTypeConverter
The default type converter
This converter supports all the basic Java types plus types. Additionally it
supports any class that defines a static fromString(String)
or
valueOf(String)
method. Finally it supports any class that defines a
constructor that takes a string.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkArguments
(String name, Class<?> type, String value) Checks that the arguments are all non-nullConvert a string value into an appropriately typed valuevoid
setNumericConverter
(NumericTypeConverter converter) Sets the numeric type converter to use, ifnull
then default behaviour of the type converter instance (whatever that might be) will be usedprotected final ConvertResult
tryConvertBasicTypes
(String name, Class<?> type, String value) Tries to convert the value if it is one of the common Java typesprotected final ConvertResult
tryConvertFromString
(String name, Class<?> type, String value) Tries to convert the value by invoking a staticfromString(String)
method on the typeprotected final ConvertResult
tryConvertFromValueOf
(String name, Class<?> type, String value) Tries to convert the value by invoking a staticvalueOf(String)
method on the typeprotected final ConvertResult
tryConvertStringConstructor
(String name, Class<?> type, String value) Tries to convert the value by invoking a constructor that takes a string on the typeprotected final ConvertResult
tryConvertStringMethod
(String name, Class<?> type, String value, String methodName) Tries to convert the value by invoking a static method on the typeMethods inherited from class com.github.rvesse.airline.types.DefaultTypeConverterProvider
getTypeConverter, getTypeConverter
-
Field Details
-
numericConverter
-
-
Constructor Details
-
DefaultTypeConverter
public DefaultTypeConverter() -
DefaultTypeConverter
-
-
Method Details
-
convert
Description copied from interface:TypeConverter
Convert a string value into an appropriately typed value- Specified by:
convert
in interfaceTypeConverter
- Parameters:
name
- Option Nametype
- Target Typevalue
- String Value- Returns:
- Typed value
-
checkArguments
Checks that the arguments are all non-null- Parameters:
name
- Option/Argument nametype
- Target typevalue
- String to convert
-
tryConvertStringConstructor
Tries to convert the value by invoking a constructor that takes a string on the type- Parameters:
type
- Typevalue
- value- Returns:
- Conversion result
-
tryConvertFromValueOf
Tries to convert the value by invoking a staticvalueOf(String)
method on the type- Parameters:
type
- Typevalue
- Value- Returns:
- Conversion result
-
tryConvertFromString
Tries to convert the value by invoking a staticfromString(String)
method on the type- Parameters:
type
- Typevalue
- Value- Returns:
- Conversion result
-
tryConvertStringMethod
protected final ConvertResult tryConvertStringMethod(String name, Class<?> type, String value, String methodName) Tries to convert the value by invoking a static method on the type- Parameters:
type
- Typevalue
- ValuemethodName
- Name of the method to invoke- Returns:
- Conversion Result
-
tryConvertBasicTypes
Tries to convert the value if it is one of the common Java types- Parameters:
type
- Typevalue
- Value- Returns:
- Conversion result
-
setNumericConverter
Description copied from interface:TypeConverter
Sets the numeric type converter to use, ifnull
then default behaviour of the type converter instance (whatever that might be) will be used- Specified by:
setNumericConverter
in interfaceTypeConverter
- Parameters:
converter
- Numeric type converter
-