|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.core.convert.support.ObjectToObjectConverter
final class ObjectToObjectConverter
Generic Converter that attempts to convert a source Object to a target type by delegating to methods on the target type.
Calls the static valueOf(sourceType)
method on the target type
to perform the conversion, if such a method exists. Else calls the target type's
Constructor that accepts a single sourceType argument, if such a Constructor exists.
Else throws a ConversionFailedException.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.springframework.core.convert.converter.GenericConverter |
---|
GenericConverter.ConvertiblePair |
Constructor Summary | |
---|---|
ObjectToObjectConverter()
|
Method Summary | |
---|---|
java.lang.Object |
convert(java.lang.Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
Convert the source to the targetType described by the TypeDescriptor. |
private static java.lang.reflect.Constructor<?> |
getConstructor(java.lang.Class<?> targetClass,
java.lang.Class<?> sourceClass)
|
java.util.Set<GenericConverter.ConvertiblePair> |
getConvertibleTypes()
Return the source and target types which this converter can convert between. |
private static java.lang.reflect.Method |
getValueOfMethodOn(java.lang.Class<?> targetClass,
java.lang.Class<?> sourceClass)
|
static boolean |
hasValueOfMethodOrConstructor(java.lang.Class<?> targetClass,
java.lang.Class<?> sourceClass)
|
boolean |
matches(TypeDescriptor sourceType,
TypeDescriptor targetType)
Should the converter from sourceType to targetType
currently under consideration be selected? |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
ObjectToObjectConverter()
Method Detail |
---|
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)
ConditionalGenericConverter
sourceType
to targetType
currently under consideration be selected?
matches
in interface ConditionalGenericConverter
sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting to
public java.util.Set<GenericConverter.ConvertiblePair> getConvertibleTypes()
GenericConverter
Each entry is a convertible source-to-target type pair.
getConvertibleTypes
in interface GenericConverter
public java.lang.Object convert(java.lang.Object source, TypeDescriptor sourceType, TypeDescriptor targetType)
GenericConverter
convert
in interface GenericConverter
source
- the source object to convert (may be null)sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting to
public static boolean hasValueOfMethodOrConstructor(java.lang.Class<?> targetClass, java.lang.Class<?> sourceClass)
private static java.lang.reflect.Method getValueOfMethodOn(java.lang.Class<?> targetClass, java.lang.Class<?> sourceClass)
private static java.lang.reflect.Constructor<?> getConstructor(java.lang.Class<?> targetClass, java.lang.Class<?> sourceClass)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |