targetType by delegating to a method on the source object or to
a static factory method or constructor on the targetType.
to[targetType.simpleName]() method on the
source object that has a return type assignable to targetType, if such
a method exists. For example, org.example.Bar Foo#toBar() is a
method that follows this convention.
valueOf(sourceType) or Java
8 style static of(sourceType) or from(sourceType)
method on the targetType that has a return type related to
targetType, if such a method exists. For example, a static
Foo.of(sourceType) method that returns a Foo,
SuperFooType, or SubFooType is a method that follows this
convention. java.time.ZoneId#of(String) is a concrete example of
such a static factory method which returns a subtype of ZoneId.
targetType that accepts
a single sourceType argument, if such a constructor exists.
ConversionFailedException or
IllegalStateException.
Warning
this converter does not support the
Object#toString() or String#valueOf(Object) methods for converting
from a sourceType to java.lang.String. For toString()
support, use FallbackObjectToStringConverter instead.
FallbackObjectToStringConverter
| Modifier and Type | Field and Description |
|---|---|
| private static final Map |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private static boolean | areRelatedTypes(Class<?> type1, Class<?> type2)
Determine if the two types reside in the same type hierarchy (i.e., type 1 is assignable to type 2 or vice versa). |
| public Object | convert(Object
the source object to convert (may be source, TypeDescriptor null)the type descriptor of the field we are converting from sourceType, TypeDescriptor the type descriptor of the field we are converting to targetType)Implements org. Convert the source object to the targetType described by the |
| private static Constructor | |
| private static Method | |
| private static Method | |
| public Set | getConvertibleTypes()
Implements org. Return the source and target types that this converter can convert between. |
| private static Executable | |
| pack-priv static boolean | |
| private static boolean | |
| public boolean | matches(TypeDescriptor
the type descriptor of the field we are converting from sourceType, TypeDescriptor the type descriptor of the field we are converting to targetType)Implements org. Should the conversion from |
| conversionExecutableCache | back to summary |
|---|---|
| private static final Map<Class<?>, Executable> conversionExecutableCache | |
| ObjectToObjectConverter | back to summary |
|---|---|
| pack-priv ObjectToObjectConverter() | |
| areRelatedTypes | back to summary |
|---|---|
| private static boolean areRelatedTypes(Class<?> type1, Class<?> type2) Determine if the two types reside in the same type hierarchy (i.e., type 1 is assignable to type 2 or vice versa).
| |
| convert | back to summary |
|---|---|
| public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) Implements org. Doc from org. Convert the source object to the targetType described by the
| |
| determineFactoryConstructor | back to summary |
|---|---|
private static Constructor
| |
| determineFactoryMethod | back to summary |
|---|---|
private static Method determineFactoryMethod(Class<?> targetClass, Class<?> sourceClass)
| |
| determineToMethod | back to summary |
|---|---|
private static Method determineToMethod(Class<?> targetClass, Class<?> sourceClass)
| |
| getConvertibleTypes | back to summary |
|---|---|
| public Set Implements org. Doc from org. Return the source and target types that this converter can convert between. Each entry is a convertible source-to-target type pair. For
| |
| getValidatedExecutable | back to summary |
|---|---|
private static Executable getValidatedExecutable(Class<?> targetClass, Class<?> sourceClass)
| |
| hasConversionMethodOrConstructor | back to summary |
|---|---|
| pack-priv static boolean hasConversionMethodOrConstructor(Class<?> targetClass, Class<?> sourceClass) | |
| isApplicable | back to summary |
|---|---|
| private static boolean isApplicable(Executable executable, Class<?> sourceClass) | |
| matches | back to summary |
|---|---|
| public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) Implements org. Doc from org. Should the conversion from
| |