java.lang.Object
com.broadleafcommerce.data.tracking.core.mapping.MappingUtils

public final class MappingUtils extends Object
Utility methods related to mapping activities in data tracking and ModelMapper
  • Method Summary

    Modifier and Type
    Method
    Description
    static <D> Class<? extends Tracking>
    getTrackingType(Class<D> domainType)
    Get the data tracking type for the repository domain type
    static Class<? extends Tracking>
    getTrackingType(Object domainInstance)
    Get the data tracking type for the repository domain instance
    static void
    includeBaseConverters(org.modelmapper.ModelMapper mapper, org.modelmapper.TypeMap typeMap, Class<?> parentSource, Class<?> parentDestination)
    TypeMap.includeBase(Class, Class) does not automatically include pre and post converters.
    static void
    includeBaseConverters(org.modelmapper.ModelMapper mapper, org.modelmapper.TypeMap typeMap, Class<?> parentSource, Class<?> parentDestination, org.modelmapper.Converter preOverride, org.modelmapper.Converter postOverride, boolean skipParentConverters)
    TypeMap.includeBase(Class, Class) does not automatically include pre and post converters.
    static void
    setupExtensions(org.modelmapper.ModelMapper mapper, Class<?> extendedSource, Class<?> extendedDestination, Class<?> parentSource, Class<?> parentDestination)
    Creates a TypeMap for the extended source and destination.
    static void
    setupExtensions(org.modelmapper.ModelMapper mapper, Class<?> extendedSource, Class<?> extendedDestination, Class<?> parentSource, Class<?> parentDestination, org.modelmapper.Converter preOverride, org.modelmapper.Converter postOverride, boolean skipParentConverters)
    Creates a TypeMap for the extended source and destination.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getTrackingType

      public static <D> Class<? extends Tracking> getTrackingType(Class<D> domainType)
      Get the data tracking type for the repository domain type
      Type Parameters:
      D - The repository domain type
      Parameters:
      domainType - The repository domain type
      Returns:
      The data tracking type
    • getTrackingType

      public static Class<? extends Tracking> getTrackingType(Object domainInstance)
      Get the data tracking type for the repository domain instance
      Parameters:
      domainInstance - The repository domain instance
      Returns:
      The data tracking type
    • includeBaseConverters

      public static void includeBaseConverters(org.modelmapper.ModelMapper mapper, org.modelmapper.TypeMap typeMap, Class<?> parentSource, Class<?> parentDestination, @Nullable org.modelmapper.Converter preOverride, @Nullable org.modelmapper.Converter postOverride, boolean skipParentConverters)
      TypeMap.includeBase(Class, Class) does not automatically include pre and post converters. They must be handled separately. This utility method makes sure those converters are registered on the passed TypeMap instance. Optionally, pre and post converter overrides may be passed, in which case, any parent converters will be called first, before calling the override. Note, if the parent converters should be skipped, then the skipParentConverters can be set to true.
      Parameters:
      mapper - The ModelMapper mapper instance
      typeMap - The inheriting (child) type map instance
      parentSource - The source type of the parent for the mapping
      parentDestination - The destination type of the parent for the mapping
      preOverride - A converter to run prior to mapping. Will also call any parent pre converters, unless skipParentConverters is true.
      postOverride - A converter to run after mapping. Will also call any parent post converters, unless skipParentConverters is true.
      skipParentConverters - Whether or not to skip parent converters
    • setupExtensions

      public static void setupExtensions(org.modelmapper.ModelMapper mapper, Class<?> extendedSource, Class<?> extendedDestination, Class<?> parentSource, Class<?> parentDestination, @Nullable org.modelmapper.Converter preOverride, @Nullable org.modelmapper.Converter postOverride, boolean skipParentConverters)
      Creates a TypeMap for the extended source and destination. Also, includes mappings from the super classes. Finally, calls includeBaseConverters(ModelMapper, TypeMap, Class, Class, Converter, Converter, boolean) to make sure any converters from the superclass are also included, while also registering the optional pre and post converters passed in.
      Parameters:
      mapper - The ModelMapper mapper instance
      extendedSource - The source type of the extension for the mapping
      extendedDestination - The destination type of the extension for the mapping
      parentSource - The source type of the parent for the mapping
      parentDestination - The destination type of the parent for the mapping
      preOverride - A converter to run prior to mapping. Will also call any parent pre converters, unless skipParentConverters is true.
      postOverride - A converter to run after mapping. Will also call any parent post converters, unless skipParentConverters is true.
      skipParentConverters - Whether or not to skip parent converters
    • setupExtensions

      public static void setupExtensions(org.modelmapper.ModelMapper mapper, Class<?> extendedSource, Class<?> extendedDestination, Class<?> parentSource, Class<?> parentDestination)
      Creates a TypeMap for the extended source and destination. Also, includes mappings from the super classes. Finally, calls includeBaseConverters(ModelMapper, TypeMap, Class, Class) to make sure any converters from the superclass are also included.
      Parameters:
      mapper - The ModelMapper mapper instance
      extendedSource - The source type of the extension for the mapping
      extendedDestination - The destination type of the extension for the mapping
      parentSource - The source type of the parent for the mapping
      parentDestination - The destination type of the parent for the mapping
    • includeBaseConverters

      public static void includeBaseConverters(org.modelmapper.ModelMapper mapper, org.modelmapper.TypeMap typeMap, Class<?> parentSource, Class<?> parentDestination)
      TypeMap.includeBase(Class, Class) does not automatically include pre and post converters. They must be handled separately. This utility method makes sure those converters are registered on the passed TypeMap instance.
      Parameters:
      mapper - The ModelMapper mapper instance
      typeMap - The inheriting (child) type map instance
      parentSource - The source type of the parent for the mapping
      parentDestination - The destination type of the parent for the mapping
      See Also: