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 of DataMapper used for mapping commercefacade's Data objects into WsDTOs.
It automatically discovers and registers managed beans of type Mapper, Converter or Filter annotated with WsDTOMapping.
  • Field Summary

    Fields inherited from interface de.hybris.platform.webservicescommons.mapping.DataMapper

    FIELD_PREFIX, FIELD_SET_NAME, MAP_NULLS
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Registers all managed beans of type Mapper, Converter or Filter and annotated with WsDTOMapping.
    void
    addConverter(ma.glasnost.orika.Converter<?,?> converter)
    Registers a Converter.
    void
    Registers a ClassMap with field mapping given by fieldMapper object
    void
    addFilter(ma.glasnost.orika.Filter<?,?> filter)
    Registers a Filter.
    void
    addMapper(ma.glasnost.orika.Mapper<?,?> mapper)
    Registers a Mapper.
    protected void
    configure(ma.glasnost.orika.MapperFactory factory)
     
    protected void
    configureFactoryBuilder(ma.glasnost.orika.impl.DefaultMapperFactory.Builder factoryBuilder)
     
    protected ma.glasnost.orika.MappingContext
    createMappingContext(Class destinationClass, String fields)
     
    protected ma.glasnost.orika.MappingContext
    createMappingContext(Class destinationClass, String fields, boolean mapNulls)
     
    protected ma.glasnost.orika.MappingContext
     
    protected ma.glasnost.orika.MappingContext
    createMappingContextForGeneric(Class destinationClass, String fields, Map<String,Class> typeVariableMap)
     
    protected Collection<Object>
    Finds all beans with annotation WsDTOMapping in current context and in parent contexts
    <S, D> void
    map(S sourceObject, D destinationObject, boolean mapNulls)
    Maps the properties of sourceObject onto destinationObject.
    <S, D> void
    map(S sourceObject, D destinationObject, String fields)
    Maps the properties of sourceObject onto destinationObject.
    <S, D> void
    map(S sourceObject, D destinationObject, String fields, boolean mapNulls)
    Maps the properties of sourceObject onto destinationObject.
    <S, D> D
    map(S sourceObject, Class<D> destinationClass, String fields)
    Create and return a new instance of type D mapped with the specified fields of sourceObject.
    <S, D> D
    map(S sourceObject, Class<D> destinationClass, Set<String> fields)
    Create and return a new instance of type D mapped with the specified fields of sourceObject.
    <S, D> void
    mapAsCollection(Iterable<S> source, Collection<D> destination, Class<D> destinationClass, String fields)
    Map an iterable onto an existing collection
    <S, D> List<D>
    mapAsList(Iterable<S> source, Class<D> destinationClass, String fields)
    Maps the source Iterable into a new List parameterized by destinationClass.
    <S, D> Set<D>
    mapAsSet(Iterable<S> source, Class<D> destinationClass, String fields)
    Maps the source iterable into a new Set parameterized by destinationClass.
    <S, D> void
    mapGeneric(S sourceObject, D destObject, Type[] sourceActualTypeArguments, Type[] destActualTypeArguments, String fields, Map<String,Class> destTypeVariableMap)
    Maps the properties of sourceObject onto destinationObject, using sourceActualTypeArguments and destActualTypeArguments to specify the arguments of parameterized types of the source and destination object.
    protected void
     
    void
    setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
     
    void
     

    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
  • Constructor Details

    • DefaultDataMapper

      public DefaultDataMapper()
  • Method Details

    • configureFactoryBuilder

      protected void configureFactoryBuilder(ma.glasnost.orika.impl.DefaultMapperFactory.Builder factoryBuilder)
      Overrides:
      configureFactoryBuilder in class ma.glasnost.orika.impl.ConfigurableMapper
    • configure

      protected void configure(ma.glasnost.orika.MapperFactory factory)
      Overrides:
      configure in class ma.glasnost.orika.impl.ConfigurableMapper
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • addAllSpringBeans

      protected void addAllSpringBeans()
      Registers all managed beans of type Mapper, Converter or Filter and annotated with WsDTOMapping.
    • getBeansForConfiguration

      protected Collection<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<Object> objectFactory)
    • addConverter

      public void addConverter(ma.glasnost.orika.Converter<?,?> converter)
      Registers a Converter.
      Parameters:
      converter - The converter.
    • addMapper

      public void addMapper(ma.glasnost.orika.Mapper<?,?> mapper)
      Registers a Mapper.
      Parameters:
      mapper - The mapper.
    • addFilter

      public void addFilter(ma.glasnost.orika.Filter<?,?> filter)
      Registers a Filter.
      Parameters:
      filter - The filter.
    • addFieldMapper

      public void addFieldMapper(FieldMapper fieldMapper)
      Registers a ClassMap with field mapping given by fieldMapper object
      Parameters:
      fieldMapper - Object storing field mapping information.
    • map

      public <S, D> D map(S sourceObject, Class<D> destinationClass, String fields)
      Description copied from interface: DataMapper
      Create and return a new instance of type D mapped with the specified fields of sourceObject.
      Specified by:
      map in interface DataMapper
      Parameters:
      sourceObject - the object to map from
      destinationClass - the type of the new object to return
      fields - comma-separated fields to map
      Returns:
      a new instance of type D mapped with the fields of sourceObject
    • map

      public <S, D> D map(S sourceObject, Class<D> destinationClass, Set<String> fields)
      Description copied from interface: DataMapper
      Create and return a new instance of type D mapped with the specified fields of sourceObject.
      Specified by:
      map in interface DataMapper
      Parameters:
      sourceObject - the object to map from
      destinationClass - the type of the new object to return
      fields - set of fully qualified field names to map
      Returns:
      a new instance of type D mapped with the fields of sourceObject
    • map

      public <S, D> void map(S sourceObject, D destinationObject, String fields)
      Description copied from interface: DataMapper
      Maps the properties of sourceObject onto destinationObject.
      Specified by:
      map in interface DataMapper
      Parameters:
      sourceObject - the object from which to read the properties
      destinationObject - the object onto which the properties should be mapped
      fields - comma-separated fields to map
    • map

      public <S, D> void map(S sourceObject, D destinationObject, String fields, boolean mapNulls)
      Description copied from interface: DataMapper
      Maps the properties of sourceObject onto destinationObject.
      Specified by:
      map in interface DataMapper
      Parameters:
      sourceObject - the object from which to read the properties
      destinationObject - the object onto which the properties should be mapped
      fields - comma-separated fields to map
      mapNulls - 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 of sourceObject onto destinationObject.
      Specified by:
      map in interface DataMapper
      Parameters:
      sourceObject - the object from which to read the properties
      destinationObject - the object onto which the properties should be mapped
      mapNulls - controls whether nulls are mapped or ignored
    • mapAsList

      public <S, D> List<D> mapAsList(Iterable<S> source, Class<D> destinationClass, String fields)
      Description copied from interface: DataMapper
      Maps the source Iterable into a new List parameterized by destinationClass.
      Specified by:
      mapAsList in interface DataMapper
      Parameters:
      source - the Iterable from which to map
      destinationClass - 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 of source.
    • mapAsSet

      public <S, D> Set<D> mapAsSet(Iterable<S> source, Class<D> destinationClass, String fields)
      Description copied from interface: DataMapper
      Maps the source iterable into a new Set parameterized by destinationClass.
      Specified by:
      mapAsSet in interface DataMapper
      Parameters:
      source - the Iterable from which to map
      destinationClass - 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 of source.
    • mapAsCollection

      public <S, D> void mapAsCollection(Iterable<S> source, Collection<D> destination, Class<D> destinationClass, String fields)
      Description copied from interface: DataMapper
      Map an iterable onto an existing collection
      Specified by:
      mapAsCollection in interface DataMapper
      Parameters:
      source - the source iterable
      destination - the destination collection
      destinationClass - the type of elements in the destination
      fields - comma-separated fields to map
    • mapGeneric

      public <S, D> void mapGeneric(S sourceObject, D destObject, Type[] sourceActualTypeArguments, Type[] destActualTypeArguments, String fields, Map<String,Class> destTypeVariableMap)
      Description copied from interface: DataMapper
      Maps the properties of sourceObject onto destinationObject, using sourceActualTypeArguments and destActualTypeArguments to specify the arguments of parameterized types of the source and destination object.
      Specified by:
      mapGeneric in interface DataMapper
      Parameters:
      sourceObject - the object from which to read the properties
      destObject - the object onto which the properties should be mapped
      sourceActualTypeArguments - arguments of source type
      e.g. if we have type class like ProductSearchPageData<SearchStateData, ProductData> we should give {SearchStateData.class,ProductData.class}
      destActualTypeArguments - arguments of dest type<br\> e.g. if we have type class like ProductSearchPageData<SearchStateData, ProductData> we should give {SearchStateData.class,ProductData.class}
      fields - comma-separated fields to map
      destTypeVariableMap - - map containing information about types used in generic class
      e.g. if we have type class like ProductSearchPageData<STATE, RESULT> we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
    • createMappingContext

      protected ma.glasnost.orika.MappingContext createMappingContext(Set<String> fields)
    • createMappingContext

      protected ma.glasnost.orika.MappingContext createMappingContext(Class destinationClass, String fields)
    • createMappingContext

      protected ma.glasnost.orika.MappingContext createMappingContext(Class destinationClass, String fields, boolean mapNulls)
    • createMappingContextForGeneric

      protected ma.glasnost.orika.MappingContext createMappingContextForGeneric(Class destinationClass, String fields, Map<String,Class> typeVariableMap)
    • setFieldSetBuilder

      public void setFieldSetBuilder(FieldSetBuilder fieldSetBuilder)