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 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

      default LinkedHashSet<String> getHeaders()
      Returns the exhaustive set of headers that specified in ExportSpecification
      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:
    • 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 of ExportDataNormalizer that will be executed to pre-process the data before writing to the file.
      Returns:
      the list of ExportDataNormalizer