Class AbstractFieldMapping

All Implemented Interfaces:
DataExceptionContributor, JsonSerializable, RecordSerializable, XmlSerializable, DataMappingProblemsSupplier, IFieldMapping, Serializable
Direct Known Subclasses:
FieldMapping

public abstract class AbstractFieldMapping extends DataMappingPart implements IFieldMapping, DataMappingProblemsSupplier
Base class for field mappings that set one target field, with an optional condition, default value expression and type conversion.
See Also:
  • Constructor Details

    • AbstractFieldMapping

      public AbstractFieldMapping()
  • Method Details

    • getDataMappingProblems

      public void getDataMappingProblems(List<DataMappingProblem> problems, boolean includeChildren)
      Description copied from interface: DataMappingProblemsSupplier
      Adds this element's problems to the list, plus those of its children when includeChildren is true; the default adds none.
      Specified by:
      getDataMappingProblems in interface DataMappingProblemsSupplier
    • getDataMappingPartName

      public String getDataMappingPartName()
      Description copied from class: DataMappingPart
      Returns the name identifying this part: the data mapping's name or a field mapping's target field name.
      Specified by:
      getDataMappingPartName in class DataMappingPart
    • getTargetFieldName

      public String getTargetFieldName()
    • setTargetFieldName

      public AbstractFieldMapping setTargetFieldName(String targetFieldName)
    • getCondition

      public LogicalExpression getCondition()
      Returns the condition for computing the field's value; when it is false the field gets the default value or null.
    • setCondition

      public AbstractFieldMapping setCondition(LogicalExpression condition)
      Sets the condition for computing the field's value; when it is false the field gets the default value or null.
    • getConditionAsString

      public String getConditionAsString()
    • getDefaultValueExpression

      public Expression getDefaultValueExpression()
      Returns the expression that supplies the field's value when the mapped value is null or the condition is false.
    • getDefaultValueExpressionAsString

      public String getDefaultValueExpressionAsString()
    • setDefaultValueExpression

      public AbstractFieldMapping setDefaultValueExpression(Expression defaultValueExpression)
      Sets the expression that supplies the field's value when the mapped value is null or the condition is false.
    • getType

      public FieldType getType()
      Returns the type the field's value is converted to, or null to keep the mapped value as is.
    • setType

      public AbstractFieldMapping setType(FieldType type)
      Sets the type the field's value is converted to, or null to keep the mapped value as is.
    • mapField

      public AbstractFieldMapping mapField(ExpressionContext expressionContext, DataMappingResult result)
      Description copied from interface: IFieldMapping
      Sets this mapping's field in the target record held by result; called by DataMapping for each record.
      Specified by:
      mapField in interface IFieldMapping
    • mapFieldImpl

      protected abstract Object mapFieldImpl(ExpressionContext expressionContext, DataMappingResult result)
      Computes the target field's value in the mapping context; called only when there is no condition or it is true. A null result falls back to the default value expression.
    • validateName

      protected void validateName()
      Throws an exception if the target field name is not set; called before each field is mapped.
    • toRecord

      public Record toRecord()
      Description copied from interface: RecordSerializable
      Converts this object's state to a record that RecordSerializable.fromRecord(Record) can load.
      Specified by:
      toRecord in interface RecordSerializable
      Overrides:
      toRecord in class Bean
    • fromRecord

      public AbstractFieldMapping fromRecord(Record source)
      Description copied from interface: RecordSerializable
      Loads this instance's state from a record and returns this (for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.
      Specified by:
      fromRecord in interface RecordSerializable
      Overrides:
      fromRecord in class Bean
      Parameters:
      source -
      Returns:
      this instance.
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: FoundationObject
      Adds this object's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Specified by:
      addExceptionProperties in interface DataExceptionContributor
      Overrides:
      addExceptionProperties in class FoundationObject
    • toXmlElement

      public Element toXmlElement(Document document)
      Description copied from interface: XmlSerializable
      Returns an element, created with document, describing this object; the default implementation throws a DataException.
      Specified by:
      toXmlElement in interface XmlSerializable
    • fromXmlElement

      public AbstractFieldMapping fromXmlElement(Element fieldMappingElement)
      Specified by:
      fromXmlElement in interface XmlSerializable