Interface DataMapper

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String FIELD_PREFIX
      Field prefix added to destination object field name
      static java.lang.String FIELD_SET_NAME
      Field set name used in mapping context
      static java.lang.String MAP_NULLS
      Flag used in mapping context.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <S,​D>
      void
      map​(S sourceObject, D destinationObject)
      Maps the properties of sourceObject onto destinationObject.
      <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)
      Create and return a new instance of type D mapped with the properties of sourceObject.
      <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.
    • Field Detail

      • FIELD_SET_NAME

        static final java.lang.String FIELD_SET_NAME
        Field set name used in mapping context
        See Also:
        Constant Field Values
      • MAP_NULLS

        static final java.lang.String MAP_NULLS
        Flag used in mapping context. Decides whether nulls are mapped or ignored.
        See Also:
        Constant Field Values
      • FIELD_PREFIX

        static final java.lang.String FIELD_PREFIX
        Field prefix added to destination object field name
        See Also:
        Constant Field Values
    • Method Detail

      • map

        <S,​D> D map​(S sourceObject,
                          java.lang.Class<D> destinationClass)
        Create and return a new instance of type D mapped with the properties of sourceObject.
        Parameters:
        sourceObject - the object to map from
        destinationClass - the type of the new object to return
        Returns:
        a new instance of type D mapped with the properties of sourceObject
      • map

        <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.
        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

        <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.
        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

        <S,​D> void map​(S sourceObject,
                             D destinationObject)
        Maps the properties of sourceObject onto destinationObject.
        Parameters:
        sourceObject - the object from which to read the properties
        destinationObject - the object onto which the properties should be mapped
      • map

        <S,​D> void map​(S sourceObject,
                             D destinationObject,
                             boolean mapNulls)
        Maps the properties of sourceObject onto destinationObject.
        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
      • map

        <S,​D> void map​(S sourceObject,
                             D destinationObject,
                             java.lang.String fields)
        Maps the properties of sourceObject onto destinationObject.
        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

        <S,​D> void map​(S sourceObject,
                             D destinationObject,
                             java.lang.String fields,
                             boolean mapNulls)
        Maps the properties of sourceObject onto destinationObject.
        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
      • mapAsSet

        <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.
        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.
      • mapAsList

        <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.
        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.
      • mapAsCollection

        <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
        Parameters:
        source - the source iterable
        destination - the destination collection
        destinationClass - the type of elements in the destination
        fields - comma-separated fields to map
      • mapGeneric

        <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.
        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}