All Implemented Interfaces:
DataExceptionContributor, JsonSerializable, RecordSerializable, XmlSerializable, Serializable

public class CalculatedField extends FoundationObject
A variable computed from an expression before a decision table or tree evaluates its rules; the result is stored in the expression context under the variable's name.
See Also:
  • Constructor Details

    • CalculatedField

      public CalculatedField()
    • CalculatedField

      public CalculatedField(String variable, String expression)
      Creates a field that is not included in the outcome.
    • CalculatedField

      public CalculatedField(String variable, String expression, boolean includeInOutcome)
  • Method Details

    • getVariable

      public String getVariable()
      Returns the name of the expression-context variable that receives the expression's result.
    • setVariable

      public CalculatedField setVariable(String variable)
      Sets the name of the expression-context variable that receives the expression's result; must not be null or empty.
    • getExpression

      public Expression getExpression()
    • getExpressionSource

      public String getExpressionSource()
      Returns the expression's source text, or null if none is set.
    • setExpression

      public CalculatedField setExpression(Expression expression)
      Sets the expression; must not be null.
    • isIncludeInOutcome

      public boolean isIncludeInOutcome()
      Indicates if this field's definition (variable and expression, not its value) is listed under fields in the decision outcome (default is false).
    • setIncludeInOutcome

      public CalculatedField setIncludeInOutcome(boolean includeInOutcome)
      Indicates if this field's definition (variable and expression, not its value) is listed under fields in the decision outcome (default is false).
    • assertValid

      public CalculatedField assertValid()
      Description copied from class: FoundationObject
      Throws a DataException if this object is invalid, otherwise returns it; the base implementation checks nothing.
      Overrides:
      assertValid in class FoundationObject
    • evaluate

      public void evaluate(DefaultExpressionContext expressionContext)
      Evaluates the expression in the given context and stores the result there under the variable name; throws a DataException if this field is invalid or the evaluation fails.
    • 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
    • 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 CalculatedField 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.
    • 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.
    • fromXmlElement

      public CalculatedField fromXmlElement(Element element)