Interface ExportSpecification
-
public interface ExportSpecification
Describes how anExportProcessor
can handle a particular export.Example usage:
public class EntityExportSpecification implements ExportSpecification { @Getter private final LinkedHashMap
fieldConfigMap = new LinkedHashMap<>(); public EntityExportSpecification() { initSpecification(); } @Override public void initSpecification() { getFieldConfigMap().put("email", "Email"); } @Override public boolean canModifyBeanSerializer(Class> beanClass) { return Entity.class.isAssignableFrom(beanClass); } } - Author:
- Vitalii Voronkov (vvoronkov)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
canModifyBeanSerializer(Class<?> beanClass)
Determine whether or not this specification can be used to modify the bean serializer.default List<ExportDataNormalizer>
getExportDataNormalizers()
The list ofExportDataNormalizer
that will be executed to pre-process the data before writing to the file.LinkedHashMap<String,String>
getFieldConfigMap()
Maintains a Map of String objects, that will be used to process the rows to an export file.default String
getHeader(String fieldName)
Returns the value for the given property name.default LinkedHashSet<String>
getHeaders()
Returns the exhaustive set of headers that specified inExportSpecification
default boolean
includeHeaders()
Whether or not include the header in the exported file.void
initSpecification()
This the main method to initialize this specification.
-
-
-
Method Detail
-
initSpecification
void initSpecification()
This the main method to initialize this specification. Usually, it should be called from the main constructor.Example usage:
... public EntityExportSpecification() { initSpecification(); } @Override public void initSpecification() { getFieldConfigMap().put("email", "Email"); } ...
-
getFieldConfigMap
LinkedHashMap<String,String> getFieldConfigMap()
Maintains a Map of String objects, that will be used to process the rows to an export file.The key of the Map should be a String representing the corresponding field name in business object.
The value of the Map should be a String representing the corresponding header name in the exported file.
- Returns:
- the configuration map
-
getHeaders
default LinkedHashSet<String> getHeaders()
Returns the exhaustive set of headers that specified inExportSpecification
- Returns:
- the exhaustive set of headers
-
getHeader
default String getHeader(String fieldName)
Returns the value for the given property name.Useful method, that exists to encapsulate specification structure and used in
SpecificationPropertiesSerializerModifier.changeProperties(SerializationConfig, BeanDescription, List)
.Provides default implementation and can be overridden in classes, that implements this interface.
- Parameters:
fieldName
- the field name in business object- Returns:
- the corresponding header name for the specified field name
-
canModifyBeanSerializer
boolean canModifyBeanSerializer(Class<?> beanClass)
Determine whether or not this specification can be used to modify the bean serializer.- Parameters:
beanClass
- the class of the bean to modify- Returns:
- true if this specification can be used to modify the bean with the specified class
- See Also:
BeanDescription.getBeanClass()
,BeanSerializerModifier
,SpecificationPropertiesSerializerModifier
-
includeHeaders
default boolean includeHeaders()
Whether or not include the header in the exported file.- Returns:
- true to include the headers and false otherwise
-
getExportDataNormalizers
default List<ExportDataNormalizer> getExportDataNormalizers()
The list ofExportDataNormalizer
that will be executed to pre-process the data before writing to the file.- Returns:
- the list of
ExportDataNormalizer
-
-