public abstract class AbstractComposedValueConverter extends AbstractGenericValueConverter<Object> implements ComposedValueConverter
ComposedValueConverter interface.| Modifier and Type | Field and Description |
|---|---|
private ReflectionUtil |
reflectionUtil |
| Constructor and Description |
|---|
AbstractComposedValueConverter()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
convert(Object value,
Object valueSource,
Class<T> targetClass)
This method converts the given
pojo to the <TARGET>-type. |
<TARGET> TARGET |
convertValue(Object value,
Object valueSource,
Class<TARGET> targetClass)
This method converts the given
value to the given type. |
<TARGET> TARGET |
convertValue(Object value,
Object valueSource,
Class<TARGET> targetClass,
Type targetType)
This method converts the given
value to the given type. |
protected void |
doInitialize()
This method performs the actual
initialization. |
ReflectionUtil |
getReflectionUtil()
This method gets the
ReflectionUtil instance to use. |
Class<Object> |
getSourceType()
This the type of the value accepted by this converter.
|
Class<Object> |
getTargetType()
Is the guaranteed return-type of the
conversion. |
void |
setReflectionUtil(ReflectionUtil reflectionUtil) |
convertValue, convertValue, convertValue, convertValuecreateLogger, getLoggerdoInitialized, getInitializationState, initializeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertconvertValue, convertValue, convertValue, convertValueprivate ReflectionUtil reflectionUtil
public AbstractComposedValueConverter()
public ReflectionUtil getReflectionUtil()
ReflectionUtil instance to use.ReflectionUtil to use.@Inject public void setReflectionUtil(ReflectionUtil reflectionUtil)
reflectionUtil - is the ReflectionUtil to Inject.protected void doInitialize()
AbstractComponentinitialization. It is called when AbstractComponent.initialize() is
invoked for the first time. super.AbstractComponent.doInitialize().doInitialize in class AbstractLoggableComponentpublic final Class<Object> getSourceType()
ValueConverterObject if you want to accept any
value. A very common source-type is String.getSourceType in interface ValueConverter<Object,Object>public final Class<Object> getTargetType()
ValueConverterconversion. This
information is used externally to choose the most specific ValueConverter that is
appropriate for the conversion. Object as target-type while a specific
converter may have Collection as target-type. Now if an object
(compliant with the source-type) needs to be converted to a
Collection or List, the specific converter is used while for other
objects the generic converter is chosen. target-type is often more general than the actual
returned result. So a ValueConverter that converts
a comma-separated String to an ArrayList will typically declare
List as target-type.getTargetType in interface ValueConverter<Object,Object>public final <T> T convert(Object value, Object valueSource, Class<T> targetClass)
ValueConverterpojo to the <TARGET>-type.convert in interface SimpleValueConverter<Object,Object>convert in interface ValueConverter<Object,Object>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.targetClass - is the type to convert the value to.value or null if the conversion is NOT possible. The returned value
has to be an instance of the given targetType.ValueConverter.convert(Object, Object, GenericType)public <TARGET> TARGET convertValue(Object value, Object valueSource, Class<TARGET> targetClass) throws ValueNotSetException, WrongValueTypeException
GenericValueConvertervalue to the given type.convertValue in interface GenericValueConverter<Object>convertValue in class AbstractGenericValueConverter<Object>TARGET - is the type to convert to.value - is the value to convert. It may be null.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.targetClass - is the type the value should be converted to.value converted to type.ValueNotSetException - if the given value is null.WrongValueTypeException - if the given value is NOT null but can NOT be converted
to the given type (e.g. if value is "12x" and type is
Integer.class).ValueNotSetExceptionWrongValueTypeExceptionpublic <TARGET> TARGET convertValue(Object value, Object valueSource, Class<TARGET> targetClass, Type targetType) throws ValueNotSetException, WrongValueTypeException
GenericValueConvertervalue to the given type.convertValue in interface GenericValueConverter<Object>TARGET - is the type to convert to.value - is the value to convert. It may be null.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.targetClass - is the type the value should be converted to. It is the raw-type of the given
targetType.targetType - is the type to convert the value to. It is potentially generic and therefore
contains more detailed information than targetClass. E.g. the targetClass may be
java.util.List while this targetType could be java.util.List<Long>. This
could help e.g. if the value is a string like "2, 47, 4252525". The caller may
supply the targetClass again here.value converted to type.ValueNotSetException - if the given value is null.WrongValueTypeException - if the given value is NOT null but can NOT be converted
to the given type (e.g. if value is "12x" and type is
Integer.class).ValueNotSetExceptionWrongValueTypeExceptionCopyright © 2001–2016 mmm-Team. All rights reserved.