Package org.joda.convert
Class TypedAdapter<T>
- java.lang.Object
-
- org.joda.convert.TypedAdapter<T>
-
- Type Parameters:
T
- the type of the converter
- All Implemented Interfaces:
FromStringConverter<T>
,StringConverter<T>
,ToStringConverter<T>
,TypedStringConverter<T>
final class TypedAdapter<T> extends java.lang.Object implements TypedStringConverter<T>
AdaptsStringConverter
toTypedStringConverter
.- Since:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private StringConverter<T>
conv
private java.lang.Class<?>
effectiveType
-
Constructor Summary
Constructors Modifier Constructor Description private
TypedAdapter(StringConverter<T> conv, java.lang.Class<?> effectiveType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static <R> TypedStringConverter<R>
adapt(java.lang.Class<R> cls, StringConverter<R> converter)
T
convertFromString(java.lang.Class<? extends T> cls, java.lang.String str)
Converts the specified object from aString
.java.lang.String
convertToString(T object)
Converts the specified object to aString
.java.lang.Class<?>
getEffectiveType()
Gets the effective type that the converter works on.java.lang.String
toString()
-
-
-
Field Detail
-
conv
private final StringConverter<T> conv
-
effectiveType
private final java.lang.Class<?> effectiveType
-
-
Constructor Detail
-
TypedAdapter
private TypedAdapter(StringConverter<T> conv, java.lang.Class<?> effectiveType)
-
-
Method Detail
-
adapt
static <R> TypedStringConverter<R> adapt(java.lang.Class<R> cls, StringConverter<R> converter)
-
convertToString
public java.lang.String convertToString(T object)
Description copied from interface:ToStringConverter
Converts the specified object to aString
.- Specified by:
convertToString
in interfaceToStringConverter<T>
- Parameters:
object
- the object to convert, not null- Returns:
- the converted string, may be null but generally not
-
convertFromString
public T convertFromString(java.lang.Class<? extends T> cls, java.lang.String str)
Description copied from interface:FromStringConverter
Converts the specified object from aString
.- Specified by:
convertFromString
in interfaceFromStringConverter<T>
- Parameters:
cls
- the class to convert to, not nullstr
- the string to convert, not null- Returns:
- the converted object, may be null but generally not
-
getEffectiveType
public java.lang.Class<?> getEffectiveType()
Description copied from interface:TypedStringConverter
Gets the effective type that the converter works on.For example, if a class declares the
FromString
andToString
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.- Specified by:
getEffectiveType
in interfaceTypedStringConverter<T>
- Returns:
- the effective type
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-