Class 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 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addAllSpringBeans()
      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 addFieldMapper​(FieldMapper fieldMapper)
      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​(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>
      void
      map​(S sourceObject, D destinationObject, boolean mapNulls)
      Maps the properties of sourceObject onto destinationObject.
      <S,​D>
      void
      map​(S sourceObject, D destinationObject, java.lang.String fields)
      Maps the properties of sourceObject onto destinationObject.
      <S,​D>
      void
      map​(S sourceObject, D destinationObject, java.lang.String fields, boolean mapNulls)
      Maps the properties of sourceObject onto destinationObject.
      <S,​D>
      D
      map​(S sourceObject, java.lang.Class<D> destinationClass, java.lang.String fields)
      Create and return a new instance of type D mapped with the specified fields of sourceObject.
      <S,​D>
      D
      map​(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 specified fields of sourceObject.
      <S,​D>
      void
      mapAsCollection​(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 by destinationClass.
      <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 by destinationClass.
      <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)
      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 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
    • Constructor Detail

      • DefaultDataMapper

        public DefaultDataMapper()
    • Method Detail

      • 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 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 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,
                                 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 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,
                                 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 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,
                                    java.lang.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,
                                    java.lang.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> 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 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> 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 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​(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 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,
                                           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 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 we should give {SearchStateData.class,ProductData.class}
        destActualTypeArguments - arguments of dest type e.g. if we have type class like ProductSearchPageData 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 we 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)