Interface DynamicHeaderFieldMapping

All Known Implementing Classes:
TranslationDynamicHeaderFieldMapping

public interface DynamicHeaderFieldMapping
While hard-coded field mappings via ImportSpecification.getHeaderFieldConfigsByRowType() are usually sufficient for most use-cases, there are some scenarios where an import specification may need more flexible, dynamic support for mapping between headers and fields where they may follow a format/pattern/template rather than match a literal value.

This interface exposes a common contract that makes it easy for specifications to delegate dynamic mapping behavior.

See Also:
  • Method Details

    • supportsMappingHeaderToField

      boolean supportsMappingHeaderToField(String header, String rowType)
      Consumers should use this method to test whether this component supports mapping the given header to a field.
      Parameters:
      header - the header value to test mapping support for
      rowType - the row type the mapping is being performed for
      Returns:
      true if this component can support mapping the given header, false otherwise
    • supportsMappingFieldToHeader

      boolean supportsMappingFieldToHeader(String field, String rowType)
      Consumers should use this method to test whether this component supports mapping the given field back to a header.
      Parameters:
      field - the field to test mapping support for
      rowType - the row type the mapping is being performed for
      Returns:
      true if this component can support mapping the given field, false otherwise
    • mapFromHeaderToField

      @Nullable String mapFromHeaderToField(String header, String rowType)
      Map the given header to its corresponding field.

      Consumers should only invoke this method on a header which has been pre-validated via supportsMappingHeaderToField(String, String).

      Parameters:
      header - the header value to map to a field
      rowType - the row type the mapping is being performed for
      Returns:
      the mapped field for the given header, or null if mapping could not successfully be completed
    • mapFromFieldToHeader

      @Nullable String mapFromFieldToHeader(String field, String rowType)
      Map the given field back to its corresponding header.

      Consumers should only invoke this method on a header which has been pre-validated via supportsMappingFieldToHeader(String, String).

      Parameters:
      field - the field to map back to a header. In most cases, this will likely just be a value that this component itself created in mapFromHeaderToField(String, String).
      rowType - the row type the mapping is being performed for
      Returns:
      the mapped header for the given field, or null if mapping could not successfully be completed