public class ComposedValueConverterImpl extends AbstractComposedValueConverter
ComposedValueConverter interface.| Modifier and Type | Class and Description |
|---|---|
protected class |
ComposedValueConverterImpl.ComposedTargetTypeConverter<TARGET>
This inner class is a composed converter for all
ValueConverters with the same
target-type. |
protected class |
ComposedValueConverterImpl.TargetClass2ConverterMap
This inner class is an
AdvancedClassHierarchyMap for ComposedValueConverterImpl.ComposedTargetTypeConverters. |
| Modifier and Type | Field and Description |
|---|---|
private List<ValueConverter<?,?>> |
converters |
private ComposedValueConverterImpl.TargetClass2ConverterMap |
targetArrayClass2converterMap |
private ComposedValueConverterImpl.TargetClass2ConverterMap |
targetClass2converterMap |
| Constructor and Description |
|---|
ComposedValueConverterImpl()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addConverter(ValueConverter<?,?> converter)
This method registers the given
converter to this composed converter. |
private ValueConverter<?,?> |
addConverterInternal(ValueConverter<?,?> converter)
This method registers the given
converter to this composed converter. |
<T> T |
convert(Object value,
Object valueSource,
GenericType<T> targetType)
This method converts the given
pojo to the <TARGET>-type. |
protected Object |
convertRecursive(Object value,
Object valueSource,
GenericType<?> targetType,
Class<?> currentTargetClass,
ValueConverter previousConverter,
ComposedValueConverterImpl.TargetClass2ConverterMap converterMap)
This method performs the
conversion recursive. |
protected void |
doInitialize()
This method performs the actual
initialization. |
(package private) List<ValueConverter<?,?>> |
getConverters() |
protected boolean |
isAccepted(Class<?> type)
This method determines if the given
type is accepted as significant type for registration and
lookup of ValueConverters. |
protected boolean |
isApplicable(Class<?> converterTargetClass,
Class<?> expectedTargetClass)
This method determines if the given
converterTargetClass is applicable for the
expectedTargetClass. |
protected boolean |
isApplicable(ValueConverter<?,?> converter,
GenericType<?> targetType)
This method determines if the given
converter is applicable for the given targetType. |
void |
setConverters(List<ValueConverter<?,?>> converterList)
|
convert, convertValue, convertValue, getReflectionUtil, getSourceType, getTargetType, setReflectionUtilconvertValue, convertValue, convertValue, convertValuecreateLogger, getLoggerdoInitialized, getInitializationState, initializeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertValue, convertValue, convertValue, convertValueprivate final ComposedValueConverterImpl.TargetClass2ConverterMap targetClass2converterMap
private final ComposedValueConverterImpl.TargetClass2ConverterMap targetArrayClass2converterMap
private List<ValueConverter<?,?>> converters
protected void doInitialize()
AbstractComponentinitialization. It is called when AbstractComponent.initialize() is
invoked for the first time. super.AbstractComponent.doInitialize().doInitialize in class AbstractComposedValueConverterpublic void addConverter(ValueConverter<?,?> converter)
converter to this composed converter.converter - is the converter to add.private ValueConverter<?,?> addConverterInternal(ValueConverter<?,?> converter)
converter to this composed converter.converter - is the converter to add.source-type and
target-type that has been replaced by converter or
null if no converter has been replaced.@Inject public void setConverters(List<ValueConverter<?,?>> converterList)
converterList - is the list of converters to register.List<ValueConverter<?,?>> getConverters()
public <T> T convert(Object value, Object valueSource, GenericType<T> targetType)
ValueConverterpojo to the <TARGET>-type.T - is the generic type of targetClass.value - is the value to convert.valueSource - describes the source of the value. This may be the filename where the value was read
from, an XPath where the value was located in an XML document, etc. It is used in exceptions
thrown if something goes wrong. This will help to find the problem easier.targetType - is the GenericType to convert the value to. It is potentially generic
and therefore contains more detailed information than a Class. E.g. the targetType
could be java.util.List<Long>. This could help e.g. if the value is a
string like "2, 47, 4252525".value or null if the conversion is NOT possible. The returned value
has to be an instance of the given targetType.protected boolean isApplicable(ValueConverter<?,?> converter, GenericType<?> targetType)
converter is applicable for the given targetType.converter - is the ValueConverter to check.targetType - is the GenericType to match with ValueConverter.getTargetType().true if the given converter is applicable, false otherwise.ValueConverter.getTargetType()protected boolean isApplicable(Class<?> converterTargetClass, Class<?> expectedTargetClass)
converterTargetClass is applicable for the
expectedTargetClass.converterTargetClass - is the target-class of the
ValueConverter to check.expectedTargetClass - is the target-class to convert to.true if the conversion is applicable.protected boolean isAccepted(Class<?> type)
type is accepted as significant type for registration and
lookup of ValueConverters. E.g. interfaces such as Cloneable or
Serializable are not more significant than Object in order to choose the
appropriate ValueConverter and should therefore be skipped when the Class-hierarchy is
recursively traversed. false the behaviour differs between interfaces
and regular classes. For an interface the entire traversal of super-interfaces is skipped, while for a
regular class, just that class is skipped, but super-classes are
recursively traversed.type - is the Class reflecting the type to check.true if the given type is acceptable, false if the given type
should be ignored.protected Object convertRecursive(Object value, Object valueSource, GenericType<?> targetType, Class<?> currentTargetClass, ValueConverter previousConverter, ComposedValueConverterImpl.TargetClass2ConverterMap converterMap)
conversion recursive.value - is the value to convert.valueSource - describes the source of the value. This may be the filename where the value was read
from, an XPath where the value was located in an XML document, etc. It is used in exceptions
thrown if something goes wrong. This will help to find the problem easier.targetType - is the GenericType to convert the value to.currentTargetClass - is the current target-type to try.previousConverter - is the converter that has been tried last time without success. It is used to
avoid trying the same converter again. Will initially be null.converterMap - is the ComposedValueConverterImpl.TargetClass2ConverterMap.value or null if the conversion is NOT possible. The returned value
has to be an instance of the given targetType.Copyright © 2001–2016 mmm-Team. All rights reserved.