Class AbstractExportRowConverter<S>
java.lang.Object
com.broadleafcommerce.common.dataexport.service.specification.AbstractExportRowConverter<S>
- All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<S,
Map<String, String>>
public abstract class AbstractExportRowConverter<S>
extends Object
implements org.springframework.core.convert.converter.Converter<S,Map<String,String>>
The base class that is used to convert from given value to a
Map
row representation. It
uses ExportSpecification
to convert only certain fields.
Example usage:
public class EntityExportRowConverter extends AbstractExportRowConverter{ public EntityExportRowConverter(ExportSpecification specification, ObjectMapper baseMapper) { super(specification, baseMapper); } @Override
public Map<String, String> convert(Entity source) { return getMapper().convertValue(source, new TypeReference<Map<String, String>>() {}); } }
- Author:
- Dima Myroniuk (dmyroniuk)
-
Constructor Summary
ConstructorDescriptionAbstractExportRowConverter
(ExportSpecification specification, com.fasterxml.jackson.databind.ObjectMapper baseMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.fasterxml.jackson.databind.ObjectMapper
configureMapper
(ExportSpecification specification, com.fasterxml.jackson.databind.ObjectMapper mapper) convertAndNormalize
(S source, Export export) Converts the given entity to aMap
row representation, then executes normalization on the result using all of theExportDataNormalizers
configured inExportSpecification.getExportDataNormalizers()
.Converts the given entity to aMap
row representation, then executes normalization on the result using all of theExportDataNormalizers
configured inExportSpecification.getExportDataNormalizers()
.Returns the exhaustive set of headers that specified inExportSpecification
.com.fasterxml.jackson.databind.ObjectMapper
protected com.fasterxml.jackson.databind.module.SimpleModule
getSpecificationExportModule
(ExportSpecification specification) protected void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.convert.converter.Converter
andThen, convert
-
Constructor Details
-
AbstractExportRowConverter
public AbstractExportRowConverter(ExportSpecification specification, com.fasterxml.jackson.databind.ObjectMapper baseMapper)
-
-
Method Details
-
getHeaders
Returns the exhaustive set of headers that specified inExportSpecification
.- Returns:
- the exhaustive set of headers
- See Also:
-
convertAndNormalize
Converts the given entity to aMap
row representation, then executes normalization on the result using all of theExportDataNormalizers
configured inExportSpecification.getExportDataNormalizers()
.- Parameters:
source
- the entity to convertexport
- the export being processed. Will be supplied to eachExportDataNormalizer
.- Returns:
- the
source
converted to a normalized row representation - See Also:
-
convertAndNormalize
public Map<String,String> convertAndNormalize(S source, Export export, @Nullable Map<String, Object> params) Converts the given entity to aMap
row representation, then executes normalization on the result using all of theExportDataNormalizers
configured inExportSpecification.getExportDataNormalizers()
.- Parameters:
source
- the entity to convertexport
- the export being processed. Will be supplied to eachExportDataNormalizer
.params
- (optional) a map of additional parameters that will be supplied to eachExportDataNormalizer
- Returns:
- the
source
converted to a normalized row representation - See Also:
-
normalizeExportDataRow
-
configureMapper
protected com.fasterxml.jackson.databind.ObjectMapper configureMapper(ExportSpecification specification, com.fasterxml.jackson.databind.ObjectMapper mapper) -
getSpecificationExportModule
protected com.fasterxml.jackson.databind.module.SimpleModule getSpecificationExportModule(ExportSpecification specification) -
getMapper
public com.fasterxml.jackson.databind.ObjectMapper getMapper() -
getSpecification
-