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,DefaultCMSDataMapper
public class DefaultDataMapper extends ma.glasnost.orika.impl.ConfigurableMapper implements DataMapper, org.springframework.context.ApplicationContextAware
Implementation ofDataMapperused for mapping commercefacade's Data objects into WsDTOs.
It automatically discovers and registers managed beans of typeMapper,ConverterorFilterannotated 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 voidaddAllSpringBeans()voidaddConverter(ma.glasnost.orika.Converter<?,?> converter)Registers aConverter.voidaddFieldMapper(FieldMapper fieldMapper)Registers aClassMapwith field mapping given by fieldMapper objectvoidaddFilter(ma.glasnost.orika.Filter<?,?> filter)Registers aFilter.voidaddMapper(ma.glasnost.orika.Mapper<?,?> mapper)Registers aMapper.protected voidconfigure(ma.glasnost.orika.MapperFactory factory)protected voidconfigureFactoryBuilder(ma.glasnost.orika.impl.DefaultMapperFactory.Builder factoryBuilder)protected ma.glasnost.orika.MappingContextcreateMappingContext(java.lang.Class destinationClass, java.lang.String fields)protected ma.glasnost.orika.MappingContextcreateMappingContext(java.lang.Class destinationClass, java.lang.String fields, boolean mapNulls)protected ma.glasnost.orika.MappingContextcreateMappingContext(java.util.Set<java.lang.String> fields)protected ma.glasnost.orika.MappingContextcreateMappingContextForGeneric(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 ofsourceObjectontodestinationObject.<S,D>
voidmap(S sourceObject, D destinationObject, java.lang.String fields)Maps the properties ofsourceObjectontodestinationObject.<S,D>
voidmap(S sourceObject, D destinationObject, java.lang.String fields, boolean mapNulls)Maps the properties ofsourceObjectontodestinationObject.<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 specifiedfieldsofsourceObject.<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 specifiedfieldsofsourceObject.<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 ofsourceObjectontodestinationObject, usingsourceActualTypeArgumentsanddestActualTypeArgumentsto specify the arguments of parameterized types of the source and destination object.protected voidregisterObjectFactory(TypeObjectFactory<java.lang.Object> objectFactory)voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetFieldSetBuilder(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:
configureFactoryBuilderin classma.glasnost.orika.impl.ConfigurableMapper
-
configure
protected void configure(ma.glasnost.orika.MapperFactory factory)
- Overrides:
configurein classma.glasnost.orika.impl.ConfigurableMapper
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
- Specified by:
setApplicationContextin 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 aClassMapwith 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:DataMapperCreate and return a new instance of type D mapped with the specifiedfieldsofsourceObject.- Specified by:
mapin 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
fieldsofsourceObject
-
map
public <S,D> D map(S sourceObject, java.lang.Class<D> destinationClass, java.util.Set<java.lang.String> fields)Description copied from interface:DataMapperCreate and return a new instance of type D mapped with the specifiedfieldsofsourceObject.- Specified by:
mapin 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
fieldsofsourceObject
-
map
public <S,D> void map(S sourceObject, D destinationObject, java.lang.String fields)Description copied from interface:DataMapperMaps the properties ofsourceObjectontodestinationObject.- Specified by:
mapin 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:DataMapperMaps the properties ofsourceObjectontodestinationObject.- Specified by:
mapin 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:DataMapperMaps the properties ofsourceObjectontodestinationObject.- Specified by:
mapin 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:DataMapperMaps the source Iterable into a new List parameterized bydestinationClass.- Specified by:
mapAsListin 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
destinationClassmapped 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:DataMapperMaps the source iterable into a new Set parameterized bydestinationClass.- Specified by:
mapAsSetin 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
destinationClassmapped 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:DataMapperMap an iterable onto an existing collection- Specified by:
mapAsCollectionin 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:DataMapperMaps the properties ofsourceObjectontodestinationObject, usingsourceActualTypeArgumentsanddestActualTypeArgumentsto specify the arguments of parameterized types of the source and destination object.- Specified by:
mapGenericin 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)
-
-