Class DefaultDataMapper
- java.lang.Object
-
- ma.glasnost.orika.impl.ConfigurableMapper
-
- de.hybris.platform.webservicescommons.mapping.impl.DefaultDataMapper
-
- All Implemented Interfaces:
DataMapper
,ma.glasnost.orika.MapperFacade
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
DefaultCMSDataMapper
public class DefaultDataMapper extends ma.glasnost.orika.impl.ConfigurableMapper implements DataMapper, org.springframework.context.ApplicationContextAware
Implementation ofDataMapper
used for mapping commercefacade's Data objects into WsDTOs.
It automatically discovers and registers managed beans of typeMapper
,Converter
orFilter
annotated withWsDTOMapping
.
-
-
Field Summary
-
Fields inherited from interface de.hybris.platform.webservicescommons.mapping.DataMapper
FIELD_PREFIX, FIELD_SET_NAME, MAP_NULLS
-
-
Constructor Summary
Constructors Constructor Description DefaultDataMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAllSpringBeans()
void
addConverter(ma.glasnost.orika.Converter<?,?> converter)
Registers aConverter
.void
addFieldMapper(FieldMapper fieldMapper)
Registers aClassMap
with field mapping given by fieldMapper objectvoid
addFilter(ma.glasnost.orika.Filter<?,?> filter)
Registers aFilter
.void
addMapper(ma.glasnost.orika.Mapper<?,?> mapper)
Registers aMapper
.protected void
configure(ma.glasnost.orika.MapperFactory factory)
protected void
configureFactoryBuilder(ma.glasnost.orika.impl.DefaultMapperFactory.Builder factoryBuilder)
protected ma.glasnost.orika.MappingContext
createMappingContext(java.lang.Class destinationClass, java.lang.String fields)
protected ma.glasnost.orika.MappingContext
createMappingContext(java.lang.Class destinationClass, java.lang.String fields, boolean mapNulls)
protected ma.glasnost.orika.MappingContext
createMappingContext(java.util.Set<java.lang.String> fields)
protected ma.glasnost.orika.MappingContext
createMappingContextForGeneric(java.lang.Class destinationClass, java.lang.String fields, java.util.Map<java.lang.String,java.lang.Class> typeVariableMap)
protected java.util.Collection<java.lang.Object>
getBeansForConfiguration()
Finds all beans with annotation WsDTOMapping in current context and in parent contexts<S,D>
voidmap(S sourceObject, D destinationObject, boolean mapNulls)
Maps the properties ofsourceObject
ontodestinationObject
.<S,D>
voidmap(S sourceObject, D destinationObject, java.lang.String fields)
Maps the properties ofsourceObject
ontodestinationObject
.<S,D>
voidmap(S sourceObject, D destinationObject, java.lang.String fields, boolean mapNulls)
Maps the properties ofsourceObject
ontodestinationObject
.<S,D>
Dmap(S sourceObject, java.lang.Class<D> destinationClass, java.lang.String fields)
Create and return a new instance of type D mapped with the specifiedfields
ofsourceObject
.<S,D>
Dmap(S sourceObject, java.lang.Class<D> destinationClass, java.util.Set<java.lang.String> fields)
Create and return a new instance of type D mapped with the specifiedfields
ofsourceObject
.<S,D>
voidmapAsCollection(java.lang.Iterable<S> source, java.util.Collection<D> destination, java.lang.Class<D> destinationClass, java.lang.String fields)
Map an iterable onto an existing collection<S,D>
java.util.List<D>mapAsList(java.lang.Iterable<S> source, java.lang.Class<D> destinationClass, java.lang.String fields)
Maps the source Iterable into a new List parameterized bydestinationClass
.<S,D>
java.util.Set<D>mapAsSet(java.lang.Iterable<S> source, java.lang.Class<D> destinationClass, java.lang.String fields)
Maps the source iterable into a new Set parameterized bydestinationClass
.<S,D>
voidmapGeneric(S sourceObject, D destObject, java.lang.reflect.Type[] sourceActualTypeArguments, java.lang.reflect.Type[] destActualTypeArguments, java.lang.String fields, java.util.Map<java.lang.String,java.lang.Class> destTypeVariableMap)
Maps the properties ofsourceObject
ontodestinationObject
, usingsourceActualTypeArguments
anddestActualTypeArguments
to specify the arguments of parameterized types of the source and destination object.protected void
registerObjectFactory(TypeObjectFactory<java.lang.Object> objectFactory)
void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
void
setFieldSetBuilder(FieldSetBuilder fieldSetBuilder)
-
Methods inherited from class ma.glasnost.orika.impl.ConfigurableMapper
convert, convert, dedicatedMapperFor, dedicatedMapperFor, dedicatedMapperFor, dedicatedMapperFor, factoryModified, init, map, map, map, map, map, map, map, map, mapAsArray, mapAsArray, mapAsArray, mapAsArray, mapAsArray, mapAsArray, mapAsArray, mapAsArray, mapAsArray, mapAsArray, mapAsCollection, mapAsCollection, mapAsCollection, mapAsCollection, mapAsCollection, mapAsCollection, mapAsCollection, mapAsCollection, mapAsList, mapAsList, mapAsList, mapAsList, mapAsList, mapAsList, mapAsList, mapAsList, mapAsList, mapAsList, mapAsMap, mapAsMap, mapAsMap, mapAsMap, mapAsMap, mapAsMap, mapAsSet, mapAsSet, mapAsSet, mapAsSet, mapAsSet, mapAsSet, mapAsSet, mapAsSet, mapAsSet, mapAsSet, newObject, resolveMappingStrategy
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.webservicescommons.mapping.DataMapper
map, map
-
-
-
-
Method Detail
-
configureFactoryBuilder
protected void configureFactoryBuilder(ma.glasnost.orika.impl.DefaultMapperFactory.Builder factoryBuilder)
- Overrides:
configureFactoryBuilder
in classma.glasnost.orika.impl.ConfigurableMapper
-
configure
protected void configure(ma.glasnost.orika.MapperFactory factory)
- Overrides:
configure
in classma.glasnost.orika.impl.ConfigurableMapper
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
addAllSpringBeans
protected void addAllSpringBeans()
-
getBeansForConfiguration
protected java.util.Collection<java.lang.Object> getBeansForConfiguration()
Finds all beans with annotation WsDTOMapping in current context and in parent contexts- Returns:
- Collection of all beans with WsDTOMapping annotation
-
registerObjectFactory
protected void registerObjectFactory(TypeObjectFactory<java.lang.Object> objectFactory)
-
addConverter
public void addConverter(ma.glasnost.orika.Converter<?,?> converter)
Registers aConverter
.- Parameters:
converter
- The converter.
-
addMapper
public void addMapper(ma.glasnost.orika.Mapper<?,?> mapper)
Registers aMapper
.- Parameters:
mapper
- The mapper.
-
addFilter
public void addFilter(ma.glasnost.orika.Filter<?,?> filter)
Registers aFilter
.- Parameters:
filter
- The filter.
-
addFieldMapper
public void addFieldMapper(FieldMapper fieldMapper)
Registers aClassMap
with field mapping given by fieldMapper object- Parameters:
fieldMapper
- Object storing field mapping information.
-
map
public <S,D> D map(S sourceObject, java.lang.Class<D> destinationClass, java.lang.String fields)
Description copied from interface:DataMapper
Create and return a new instance of type D mapped with the specifiedfields
ofsourceObject
.- Specified by:
map
in interfaceDataMapper
- Parameters:
sourceObject
- the object to map fromdestinationClass
- the type of the new object to returnfields
- comma-separated fields to map- Returns:
- a new instance of type D mapped with the
fields
ofsourceObject
-
map
public <S,D> D map(S sourceObject, java.lang.Class<D> destinationClass, java.util.Set<java.lang.String> fields)
Description copied from interface:DataMapper
Create and return a new instance of type D mapped with the specifiedfields
ofsourceObject
.- Specified by:
map
in interfaceDataMapper
- Parameters:
sourceObject
- the object to map fromdestinationClass
- the type of the new object to returnfields
- set of fully qualified field names to map- Returns:
- a new instance of type D mapped with the
fields
ofsourceObject
-
map
public <S,D> void map(S sourceObject, D destinationObject, java.lang.String fields)
Description copied from interface:DataMapper
Maps the properties ofsourceObject
ontodestinationObject
.- Specified by:
map
in interfaceDataMapper
- Parameters:
sourceObject
- the object from which to read the propertiesdestinationObject
- the object onto which the properties should be mappedfields
- comma-separated fields to map
-
map
public <S,D> void map(S sourceObject, D destinationObject, java.lang.String fields, boolean mapNulls)
Description copied from interface:DataMapper
Maps the properties ofsourceObject
ontodestinationObject
.- Specified by:
map
in interfaceDataMapper
- Parameters:
sourceObject
- the object from which to read the propertiesdestinationObject
- the object onto which the properties should be mappedfields
- comma-separated fields to mapmapNulls
- controls whether nulls are mapped or ignored
-
map
public <S,D> void map(S sourceObject, D destinationObject, boolean mapNulls)
Description copied from interface:DataMapper
Maps the properties ofsourceObject
ontodestinationObject
.- Specified by:
map
in interfaceDataMapper
- Parameters:
sourceObject
- the object from which to read the propertiesdestinationObject
- the object onto which the properties should be mappedmapNulls
- controls whether nulls are mapped or ignored
-
mapAsList
public <S,D> java.util.List<D> mapAsList(java.lang.Iterable<S> source, java.lang.Class<D> destinationClass, java.lang.String fields)
Description copied from interface:DataMapper
Maps the source Iterable into a new List parameterized bydestinationClass
.- Specified by:
mapAsList
in interfaceDataMapper
- Parameters:
source
- the Iterable from which to mapdestinationClass
- the type of elements to be contained in the returned Set.fields
- comma-separated fields to map- Returns:
- a new List containing elements of type
destinationClass
mapped from the elements ofsource
.
-
mapAsSet
public <S,D> java.util.Set<D> mapAsSet(java.lang.Iterable<S> source, java.lang.Class<D> destinationClass, java.lang.String fields)
Description copied from interface:DataMapper
Maps the source iterable into a new Set parameterized bydestinationClass
.- Specified by:
mapAsSet
in interfaceDataMapper
- Parameters:
source
- the Iterable from which to mapdestinationClass
- the type of elements to be contained in the returned Set.fields
- comma-separated fields to map- Returns:
- a new Set containing elements of type
destinationClass
mapped from the elements ofsource
.
-
mapAsCollection
public <S,D> void mapAsCollection(java.lang.Iterable<S> source, java.util.Collection<D> destination, java.lang.Class<D> destinationClass, java.lang.String fields)
Description copied from interface:DataMapper
Map an iterable onto an existing collection- Specified by:
mapAsCollection
in interfaceDataMapper
- Parameters:
source
- the source iterabledestination
- the destination collectiondestinationClass
- the type of elements in the destinationfields
- comma-separated fields to map
-
mapGeneric
public <S,D> void mapGeneric(S sourceObject, D destObject, java.lang.reflect.Type[] sourceActualTypeArguments, java.lang.reflect.Type[] destActualTypeArguments, java.lang.String fields, java.util.Map<java.lang.String,java.lang.Class> destTypeVariableMap)
Description copied from interface:DataMapper
Maps the properties ofsourceObject
ontodestinationObject
, usingsourceActualTypeArguments
anddestActualTypeArguments
to specify the arguments of parameterized types of the source and destination object.- Specified by:
mapGeneric
in interfaceDataMapper
- Parameters:
sourceObject
- the object from which to read the propertiesdestObject
- the object onto which the properties should be mappedsourceActualTypeArguments
- arguments of source type
e.g. if we have type class like ProductSearchPageDatawe should give {SearchStateData.class,ProductData.class} destActualTypeArguments
- arguments of dest type
e.g. if we have type class like ProductSearchPageDatawe should give {SearchStateData.class,ProductData.class} fields
- comma-separated fields to mapdestTypeVariableMap
- - map containing information about types used in generic class
e.g. if we have type class like ProductSearchPageDatawe should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
-
createMappingContext
protected ma.glasnost.orika.MappingContext createMappingContext(java.util.Set<java.lang.String> fields)
-
createMappingContext
protected ma.glasnost.orika.MappingContext createMappingContext(java.lang.Class destinationClass, java.lang.String fields)
-
createMappingContext
protected ma.glasnost.orika.MappingContext createMappingContext(java.lang.Class destinationClass, java.lang.String fields, boolean mapNulls)
-
createMappingContextForGeneric
protected ma.glasnost.orika.MappingContext createMappingContextForGeneric(java.lang.Class destinationClass, java.lang.String fields, java.util.Map<java.lang.String,java.lang.Class> typeVariableMap)
-
setFieldSetBuilder
public void setFieldSetBuilder(FieldSetBuilder fieldSetBuilder)
-
-