Package net.sf.ezmorph.bean
Class BeanMorpher
java.lang.Object
net.sf.ezmorph.bean.BeanMorpher
- All Implemented Interfaces:
Morpher
,ObjectMorpher
Converts a JavaBean into another JavaBean or DynaBean.
This Morpher will try to match every property from the target JavaBean's class to the properties of the source JavaBean. If any target property differs in type from the source property, it will try to morph it. If a Morpher is not found for that type, the conversion will be aborted with a MorphException; this may be changed by setting the Morpher to be lenient, in that way it will ignore the property (the resulting value will be null).
This Morpher will try to match every property from the target JavaBean's class to the properties of the source JavaBean. If any target property differs in type from the source property, it will try to morph it. If a Morpher is not found for that type, the conversion will be aborted with a MorphException; this may be changed by setting the Morpher to be lenient, in that way it will ignore the property (the resulting value will be null).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class
private boolean
private static final org.apache.commons.logging.Log
private final MorpherRegistry
-
Constructor Summary
ConstructorsConstructorDescriptionBeanMorpher
(Class beanClass, MorpherRegistry morpherRegistry) BeanMorpher
(Class beanClass, MorpherRegistry morpherRegistry, boolean lenient) -
Method Summary
Modifier and TypeMethodDescriptionMorphs the input object into an output object of the supported type.morphsTo()
Returns the target Class for conversion.private void
boolean
Returns true if the Morpher supports conversion from this Class.private void
validateClass
(Class clazz)
-
Field Details
-
log
private static final org.apache.commons.logging.Log log -
beanClass
-
lenient
private boolean lenient -
morpherRegistry
-
-
Constructor Details
-
BeanMorpher
- Parameters:
beanClass
- the target class to morph tomorpherRegistry
- a registry of morphers
-
BeanMorpher
- Parameters:
beanClass
- the target class to morph tomorpherRegistry
- a registry of morpherslenient
- if an exception should be raised if no morpher is found for a target property
-
-
Method Details
-
morph
Description copied from interface:ObjectMorpher
Morphs the input object into an output object of the supported type.- Specified by:
morph
in interfaceObjectMorpher
- Parameters:
sourceBean
- The input value to be morphed
-
morphsTo
Description copied from interface:Morpher
Returns the target Class for conversion. -
supports
Description copied from interface:Morpher
Returns true if the Morpher supports conversion from this Class. -
setProperty
private void setProperty(Object targetBean, String name, Class sourceType, Class targetType, Object value) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException -
validateClass
-