Interface ExportSpecification
public interface ExportSpecification
Describes how an
ExportProcessor can handle a particular export.
Example usage:
public class EntityExportSpecification implements ExportSpecification {
@Getter
private final LinkedHashMap<String, String> 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
Modifier and TypeMethodDescriptionbooleancanModifyBeanSerializer(Class<?> beanClass) Determine whether or not this specification can be used to modify the bean serializer.default List<ExportDataNormalizer>The list ofExportDataNormalizerthat will be executed to pre-process the data before writing to the file.Maintains a Map of String objects, that will be used to process the rows to an export file.default StringReturns the value for the given property name.default LinkedHashSet<String>Returns the exhaustive set of headers that specified inExportSpecificationdefault booleanWhether or not include the header in the exported file.voidThis the main method to initialize this specification.
-
Method Details
-
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
Returns the exhaustive set of headers that specified inExportSpecification- Returns:
- the exhaustive set of headers
-
getHeader
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
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()BeanSerializerModifierSpecificationPropertiesSerializerModifier
-
includeHeaders
default boolean includeHeaders()Whether or not include the header in the exported file.- Returns:
- true to include the headers and false otherwise
-
getExportDataNormalizers
The list ofExportDataNormalizerthat will be executed to pre-process the data before writing to the file.- Returns:
- the list of
ExportDataNormalizer
-