Interface BeanMapper
-
- All Known Implementing Classes:
AbstractBeanMapper,BeanMapperImplDozer,BeanMapperImplOrika
public interface BeanMapperThis is the interface used to convert from one Java bean to another compatible bean (e.g. from a JPA entity to a corresponding transfer-object).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> Tmap(Object source, Class<T> targetClass)<T> List<T>mapList(List<?> source, Class<T> targetClass)<T> List<T>mapList(List<?> source, Class<T> targetClass, boolean suppressNullValues)<T> Set<T>mapSet(Set<?> source, Class<T> targetClass)<T> Set<T>mapSet(Set<?> source, Class<T> targetClass, boolean suppressNullValues)<API,S extends API,T extends API>
TmapTypesafe(Class<API> apiClass, S source, Class<T> targetClass)A type-safe variant ofmap(Object, Class)to prevent accidental abuse (e.g.
-
-
-
Method Detail
-
map
<T> T map(Object source, Class<T> targetClass)
- Type Parameters:
T- is the generic type to convert to.- Parameters:
source- is the object to convert.targetClass- is theClassreflecting the type to convert to.- Returns:
- the converted object. Will be
nullifsourceisnull.
-
mapTypesafe
<API,S extends API,T extends API> T mapTypesafe(Class<API> apiClass, S source, Class<T> targetClass)
A type-safe variant ofmap(Object, Class)to prevent accidental abuse (e.g. mapping of apples to bananas).- Type Parameters:
API- is a common super-type (interface) ofsourceandtargetType.S- is the generic type ofsource.T- is the generic type to convert to (target).- Parameters:
apiClass- is theClassreflecting the <API>.source- is the object to convert.targetClass- is theClassreflecting the type to convert to.- Returns:
- the converted object. Will be
nullifsourceisnull. - Since:
- 1.3.0
-
mapList
<T> List<T> mapList(List<?> source, Class<T> targetClass)
Creates a newListwith themapped beanfor eachentryof the givenList. UsesfalseforsuppressNullValues(seemapList(List, Class, boolean)).
-
mapList
<T> List<T> mapList(List<?> source, Class<T> targetClass, boolean suppressNullValues)
- Type Parameters:
T- is the generic type to convert theListentries to.- Parameters:
source- is theListwith the source objects.targetClass- is theClassreflecting the type to convert eachListentry to.suppressNullValues-trueifnullvalues shall be suppressed/omitted in the resultingList,falseotherwise.- Returns:
- the
Listwith the converted objects. Will beemptyissourceis empty ornull. - Since:
- 1.3.0
-
mapSet
<T> Set<T> mapSet(Set<?> source, Class<T> targetClass)
Creates a newSetwith themapped beanfor eachentryof the givenSet. UsesfalseforsuppressNullValues(seemapSet(Set, Class, boolean)).
-
mapSet
<T> Set<T> mapSet(Set<?> source, Class<T> targetClass, boolean suppressNullValues)
- Type Parameters:
T- is the generic type to convert theSetentries to.- Parameters:
source- is theSetwith the source objects.targetClass- is theClassreflecting the type to convert eachSetentry to.suppressNullValues-trueifnullvalues shall be suppressed/omitted in the resultingSet,falseotherwise.- Returns:
- the
Setwith the converted objects. Will beemptyissourceis empty ornull. - Since:
- 1.3.0
-
-