Class MappingUtils
java.lang.Object
com.broadleafcommerce.data.tracking.core.mapping.MappingUtils
Utility methods related to mapping activities in data tracking and ModelMapper
-
Method Summary
Modifier and TypeMethodDescriptiongetTrackingType
(Class<D> domainType) Get the data tracking type for the repository domain typegetTrackingType
(Object domainInstance) Get the data tracking type for the repository domain instancestatic 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 aTypeMap
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 aTypeMap
for the extended source and destination.
-
Method Details
-
getTrackingType
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
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 passedTypeMap
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 theskipParentConverters
can be set to true.- Parameters:
mapper
- The ModelMapper mapper instancetypeMap
- The inheriting (child) type map instanceparentSource
- The source type of the parent for the mappingparentDestination
- The destination type of the parent for the mappingpreOverride
- A converter to run prior to mapping. Will also call any parent pre converters, unlessskipParentConverters
is true.postOverride
- A converter to run after mapping. Will also call any parent post converters, unlessskipParentConverters
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 aTypeMap
for the extended source and destination. Also, includes mappings from the super classes. Finally, callsincludeBaseConverters(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 instanceextendedSource
- The source type of the extension for the mappingextendedDestination
- The destination type of the extension for the mappingparentSource
- The source type of the parent for the mappingparentDestination
- The destination type of the parent for the mappingpreOverride
- A converter to run prior to mapping. Will also call any parent pre converters, unlessskipParentConverters
is true.postOverride
- A converter to run after mapping. Will also call any parent post converters, unlessskipParentConverters
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 aTypeMap
for the extended source and destination. Also, includes mappings from the super classes. Finally, callsincludeBaseConverters(ModelMapper, TypeMap, Class, Class)
to make sure any converters from the superclass are also included.- Parameters:
mapper
- The ModelMapper mapper instanceextendedSource
- The source type of the extension for the mappingextendedDestination
- The destination type of the extension for the mappingparentSource
- The source type of the parent for the mappingparentDestination
- 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 passedTypeMap
instance.- Parameters:
mapper
- The ModelMapper mapper instancetypeMap
- The inheriting (child) type map instanceparentSource
- The source type of the parent for the mappingparentDestination
- The destination type of the parent for the mapping- See Also:
-