This is the most flexible of the Converter SPI interfaces, but also the most complex.
It is flexible in that a GenericConverter may support converting between multiple source/target
type pairs (see getConvertibleTypes()). In addition, GenericConverter implementations
have access to source/target field context during the type conversion
process. This allows for resolving source and target field metadata such as annotations and
generics information, which can be used to influence the conversion logic.
This interface should generally not be used when the simpler Converter or
ConverterFactory interface is sufficient.
Implementations may additionally implement ConditionalConverter.
TypeDescriptor, Converter, ConverterFactory, ConditionalConverter
| Modifier and Type | Class and Description |
|---|---|
| public static class | GenericConverter.ConvertiblePair
Holder for a source-to-target class pair. |
| Modifier and Type | Method and Description |
|---|---|
| public Object | Returns: the converted objectthe 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)Convert the source object to the targetType described by the |
| public Set |
| convert | back to summary |
|---|---|
| public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) Convert the source object to the targetType described by the
| |
| getConvertibleTypes | back to summary |
|---|---|
| public Set Return the source and target types that this converter can convert between. Each entry is a convertible source-to-target type pair. For
| |
| Access | Constructor and Description |
|---|---|
| public | ConvertiblePair(Class<?>
the source type sourceType, Class<?> the target type targetType)Create a new source-to-target pair. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. |
| public Class | |
| public Class | |
| public int | |
| public String |
| sourceType | back to summary |
|---|---|
| private final Class<?> sourceType | |
| targetType | back to summary |
|---|---|
| private final Class<?> targetType | |
| ConvertiblePair | back to summary |
|---|---|
| public ConvertiblePair(Class<?> sourceType, Class<?> targetType) Create a new source-to-target pair. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getSourceType | back to summary |
|---|---|
| public Class | |
| getTargetType | back to summary |
|---|---|
| public Class | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |