public class BeanMapper extends Object
Constructor and Description |
---|
BeanMapper()
Construct a new bean mapper, with default converters.
|
BeanMapper(boolean includeDefaultConverters)
Construct a new bean mapper.
|
Modifier and Type | Method and Description |
---|---|
void |
addConverter(BeanConverter converter)
Add a converter class (must inherit from abstract BeanConverter class) to the beanMapper.
|
void |
addPackagePrefix(Class<?> clazz)
Adds a package on the basis of a class.
|
void |
addProxySkipClass(Class<?> clazz)
Add classes to skip while unproxying to prevent failing of the BeanMapper while mapping
proxy classes or classes containing synthetic fields (Like ENUM types).
|
Object |
convert(Object value,
Class<?> targetClass)
Converts a value into the target class.
|
<S,T> Collection<T> |
map(Collection<S> sourceItems,
Class<T> targetClass)
Maps a list of source items to a list of target items with a specific class
|
<S,T> T |
map(S source,
Class<T> targetClass)
Copies the values from the source object to a newly constructed target instance
|
<S,T> T |
map(S source,
Class<T> targetClass,
BeanInitializer beanInitializer)
Copies the values from the source object to a newly constructed target instance
|
<S,T> T |
map(S source,
T target)
Copies the values from the source object to an existing target instance
|
void |
setBeanInitializer(BeanInitializer beanInitializer) |
void |
setBeanUnproxy(BeanUnproxy beanUnproxy) |
public BeanMapper()
public BeanMapper(boolean includeDefaultConverters)
includeDefaultConverters
- whether default converters should be registeredpublic <S,T> T map(S source, Class<T> targetClass)
S
- The instance from which the properties get copiedT
- the instance to which the properties get copiedsource
- source instance of the propertiestargetClass
- class of the target, needs to be constructed as the target instanceBeanMappingException
public <S,T> T map(S source, Class<T> targetClass, BeanInitializer beanInitializer)
S
- The instance from which the properties get copiedT
- the instance to which the properties get copiedsource
- source instance of the propertiestargetClass
- class of the target, needs to be constructed as the target instancebeanInitializer
- initializes the beansBeanMappingException
public <S,T> Collection<T> map(Collection<S> sourceItems, Class<T> targetClass)
S
- sourceT
- targetsourceItems
- the items to be mappedtargetClass
- the class type of the items in the returned listBeanMappingException
public <S,T> T map(S source, T target)
S
- The instance from which the properties get copied.T
- the instance to which the properties get copiedsource
- source instance of the propertiestarget
- target instance for the propertiesBeanMappingException
public Object convert(Object value, Class<?> targetClass)
value
- the value to converttargetClass
- the target classpublic final void addPackagePrefix(Class<?> clazz)
clazz
- the class which sets the package prefix for all mappable classespublic final void addConverter(BeanConverter converter)
converter
- an instance of the class that contains the conversion method implementations and inherits
from the abstract BeanConverter class.public final void addProxySkipClass(Class<?> clazz)
clazz
- the class that is added to the list of skipped classespublic final void setBeanInitializer(BeanInitializer beanInitializer)
public final void setBeanUnproxy(BeanUnproxy beanUnproxy)
Copyright © 2015 42 BV. All Rights Reserved.