SOURCE
- is the generic source-type
.TARGET
- is the generic target-type
.public abstract class AbstractValueConverterToCompatiblePojo<SOURCE,TARGET> extends AbstractRecursiveValueConverter<SOURCE,TARGET>
ValueConverter
interface
that converts an POJO to a POJO with the same properties. E.g. this can be useful when you convert to
transfer-objects.Modifier and Type | Field and Description |
---|---|
private PojoDescriptorBuilder |
pojoDescriptorBuilder |
private PojoDescriptorBuilderFactory |
pojoDescriptorBuilderFactory |
private PojoFactory |
pojoFactory |
Constructor and Description |
---|
AbstractValueConverterToCompatiblePojo()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
<T extends TARGET> |
convert(SOURCE value,
Object valueSource,
GenericType<T> targetType)
This method converts the given
pojo to the <TARGET>-type. |
protected void |
doInitialize()
This method performs the actual
initialization . |
protected PojoDescriptorBuilder |
getPojoDescriptorBuilder() |
protected PojoDescriptorBuilderFactory |
getPojoDescriptorBuilderFactory() |
protected void |
handleNoGetterForSetter(PojoPropertyAccessorOneArg setter,
Class<?> targetClass,
Object sourceObject,
Class<?> sourceClass)
Called if the target object of the conversion has a setter that has no corresponding getter in the source
object to convert.
|
void |
setPojoDescriptorBuilder(PojoDescriptorBuilder pojoDescriptorBuilder)
This method sets the
PojoDescriptorBuilder instance to use. |
void |
setPojoDescriptorBuilderFactory(PojoDescriptorBuilderFactory pojoDescriptorBuilderFactory)
This method sets the
PojoDescriptorBuilderFactory instance to use. |
void |
setPojoFactory(PojoFactory pojoFactory)
This method sets the
PojoFactory instance to used to create new instances of POJOs. |
getComposedValueConverter, setComposedValueConverter
convert, getReflectionUtil, setReflectionUtil
createLogger, getLogger
doInitialized, getInitializationState, initialize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSourceType, getTargetType
private PojoFactory pojoFactory
private PojoDescriptorBuilder pojoDescriptorBuilder
private PojoDescriptorBuilderFactory pojoDescriptorBuilderFactory
public AbstractValueConverterToCompatiblePojo()
protected void doInitialize()
AbstractComponent
initialization
. It is called when AbstractComponent.initialize()
is
invoked for the first time. super.
AbstractComponent.doInitialize()
.doInitialize
in class AbstractRecursiveValueConverter<SOURCE,TARGET>
public <T extends TARGET> T convert(SOURCE value, Object valueSource, GenericType<T> targetType) throws ValueException
ValueConverter
pojo
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
.ValueException
- if the conversion failed (e.g. the given value
is illegal for the given
targetClass
).ValueException
protected void handleNoGetterForSetter(PojoPropertyAccessorOneArg setter, Class<?> targetClass, Object sourceObject, Class<?> sourceClass)
@Inject public void setPojoFactory(PojoFactory pojoFactory)
PojoFactory
instance to used to create new instances of POJOs.pojoFactory
- is the PojoFactory
to use.protected PojoDescriptorBuilder getPojoDescriptorBuilder()
PojoDescriptorBuilder
.public void setPojoDescriptorBuilder(PojoDescriptorBuilder pojoDescriptorBuilder)
PojoDescriptorBuilder
instance to use. If no such instance is set, the
factory
has to be set and an
individual instance will be created automatically on initialization
.pojoDescriptorBuilder
- is the PojoDescriptorBuilder
to use.@Inject public void setPojoDescriptorBuilderFactory(PojoDescriptorBuilderFactory pojoDescriptorBuilderFactory)
PojoDescriptorBuilderFactory
instance to use.pojoDescriptorBuilderFactory
- is the pojoDescriptorBuilderFactory to setprotected PojoDescriptorBuilderFactory getPojoDescriptorBuilderFactory()
Copyright © 2001–2016 mmm-Team. All rights reserved.