public class TypeConverterManager
extends java.lang.Object
Constructor and Description |
---|
TypeConverterManager() |
Modifier and Type | Method and Description |
---|---|
<C extends java.util.Collection<T>,T> |
convertToCollection(java.lang.Object value,
java.lang.Class<? extends java.util.Collection> destinationType,
java.lang.Class<T> componentType)
Special case of
convertType(Object, Class) when target is collection and
when component type is known. |
<T> T |
convertType(java.lang.Object value,
java.lang.Class<T> destinationType)
Converts an object to destination type.
|
static TypeConverterManager |
get()
Returns default implementation.
|
<T> TypeConverter<T> |
lookup(java.lang.Class<T> type)
Retrieves converter for provided type.
|
<T> void |
register(java.lang.Class<T> type,
TypeConverter<T> typeConverter)
Registers a converter for specified type.
|
void |
registerDefaults()
Registers default set of converters.
|
void |
unregister(java.lang.Class type)
Un-registers converter for given type.
|
public static TypeConverterManager get()
public void registerDefaults()
public <T> void register(java.lang.Class<T> type, TypeConverter<T> typeConverter)
type
- class that converter is fortypeConverter
- converter for provided classpublic void unregister(java.lang.Class type)
public <T> TypeConverter<T> lookup(java.lang.Class<T> type)
null
public <T> T convertType(java.lang.Object value, java.lang.Class<T> destinationType)
TypeConverter
will be used. If not, it scans of destination is
an array or enum, as those two cases are handled in a special way.
If destination type is one of common types, consider using Converter
instead for somewhat faster approach (no lookup).
public <C extends java.util.Collection<T>,T> C convertToCollection(java.lang.Object value, java.lang.Class<? extends java.util.Collection> destinationType, java.lang.Class<T> componentType)
convertType(Object, Class)
when target is collection and
when component type is known.Copyright © 2003-present Jodd Team