|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.component.base.AbstractComponent
net.sf.mmm.util.component.base.AbstractLoggableComponent
net.sf.mmm.util.value.base.AbstractValueConverter<SOURCE,TARGET>
net.sf.mmm.util.value.base.AbstractRecursiveValueConverter<Object,Object>
net.sf.mmm.util.value.impl.ValueConverterToCompatiblePojo
@Singleton @Named public class ValueConverterToCompatiblePojo
This is an implementation of the
ValueConverter interface that converts an
POJO to a POJO with the same properties. E.g. this can be useful when you
have generated transport-objects (maybe from some strange
web-service-framework) and want to convert those from or to your nice
equivalent handwritten POJOs.
| Field Summary | |
|---|---|
private PojoDescriptorBuilder |
pojoDescriptorBuilder
|
private PojoDescriptorBuilderFactory |
pojoDescriptorBuilderFactory
|
private PojoFactory |
pojoFactory
|
| Constructor Summary | |
|---|---|
ValueConverterToCompatiblePojo()
The constructor. |
|
| Method Summary | |
|---|---|
Object |
convert(Object value,
Object valueSource,
GenericType<? extends Object> 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()
|
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 |
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. |
| Methods inherited from class net.sf.mmm.util.value.base.AbstractRecursiveValueConverter |
|---|
getComposedValueConverter, setComposedValueConverter |
| Methods inherited from class net.sf.mmm.util.value.base.AbstractValueConverter |
|---|
convert, getReflectionUtil, setReflectionUtil |
| Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent |
|---|
getLogger, setLogger |
| Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent |
|---|
doInitialized, getInitializationState, initialize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private PojoFactory pojoFactory
setPojoFactory(PojoFactory)private PojoDescriptorBuilder pojoDescriptorBuilder
setPojoDescriptorBuilder(PojoDescriptorBuilder)private PojoDescriptorBuilderFactory pojoDescriptorBuilderFactory
setPojoDescriptorBuilderFactory(PojoDescriptorBuilderFactory)| Constructor Detail |
|---|
public ValueConverterToCompatiblePojo()
| Method Detail |
|---|
protected void doInitialize()
initialization. It is
called when AbstractComponent.initialize() is invoked for the first time.super.AbstractComponent.doInitialize().
doInitialize in class AbstractRecursiveValueConverter<Object,Object>public Class<Object> getSourceType()
Object
if you want to accept any value. A very common source-type is String.
public Class<Object> getTargetType()
conversion. 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.
public Object convert(Object value,
Object valueSource,
GenericType<? extends Object> targetType)
throws ValueException
pojo to the
<TARGET>-type.
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).@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()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||