T - the type of the converterfinal class MethodsStringConverter<T> extends ReflectionStringConverter<T>
The toString method must meet the following signature:
String anyName() on Class T.
The fromString method must meet the following signature:
static T anyName(String) on any class.
MethodsStringConverter is thread-safe and immutable.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Class<?> |
effectiveType
Effective type.
|
private java.lang.reflect.Method |
fromString
Conversion from a string.
|
| Constructor and Description |
|---|
MethodsStringConverter(java.lang.Class<T> cls,
java.lang.reflect.Method toString,
java.lang.reflect.Method fromString,
java.lang.Class<?> effectiveType)
Creates an instance using two methods.
|
| Modifier and Type | Method and Description |
|---|---|
T |
convertFromString(java.lang.Class<? extends T> cls,
java.lang.String str)
Converts the
String to an object. |
java.lang.Class<?> |
getEffectiveType()
Gets the effective type that the converter works on.
|
convertToString, toStringprivate final java.lang.reflect.Method fromString
private final java.lang.Class<?> effectiveType
MethodsStringConverter(java.lang.Class<T> cls, java.lang.reflect.Method toString, java.lang.reflect.Method fromString, java.lang.Class<?> effectiveType)
cls - the class this converts for, not nulltoString - the toString method, not nullfromString - the fromString method, not nulljava.lang.RuntimeException - (or subclass) if the method signatures are invalidpublic T convertFromString(java.lang.Class<? extends T> cls, java.lang.String str)
String to an object.cls - the class to convert to, not nullstr - the string to convert, not nullpublic java.lang.Class<?> getEffectiveType()
TypedStringConverter
For example, if a class declares the FromString and ToString
then the effective type of the converter is that class. If a subclass is
queried for a converter, then the effective type is that of the superclass.