Class CalculatedField
java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.core.FoundationObject
com.northconcepts.datapipeline.foundations.expression.CalculatedField
- All Implemented Interfaces:
DataExceptionContributor,JsonSerializable,RecordSerializable,XmlSerializable,Serializable
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:
-
Field Summary
Fields inherited from class com.northconcepts.datapipeline.foundations.core.FoundationObject
internalId, internalName, log, TIMESTAMP_FORMATFields inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
SERIALIZED_CLASS_NAME, TYPEFields inherited from interface com.northconcepts.datapipeline.core.XmlSerializable
XML_SERIALIZED_CLASS_NAME -
Constructor Summary
ConstructorsConstructorDescriptionCalculatedField(String variable, String expression) Creates a field that is not included in the outcome.CalculatedField(String variable, String expression, boolean includeInOutcome) -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this object's current state to aDataException.Throws aDataExceptionif this object is invalid, otherwise returns it; the base implementation checks nothing.voidevaluate(DefaultExpressionContext expressionContext) Evaluates the expression in the given context and stores the result there under the variable name; throws aDataExceptionif this field is invalid or the evaluation fails.fromRecord(Record source) Loads this instance's state from a record and returnsthis(for fluid API call chaining).fromXmlElement(Element element) ExpressionReturns the expression's source text, ornullif none is set.Returns the name of the expression-context variable that receives the expression's result.booleanIndicates if this field's definition (variable and expression, not its value) is listed underfieldsin the decision outcome (default is false).setExpression(Expression expression) Sets the expression; must not be null.setIncludeInOutcome(boolean includeInOutcome) Indicates if this field's definition (variable and expression, not its value) is listed underfieldsin the decision outcome (default is false).setVariable(String variable) Sets the name of the expression-context variable that receives the expression's result; must not be null or empty.toRecord()Converts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.toXmlElement(Document document) Returns an element, created withdocument, describing this object; the default implementation throws aDataException.Methods inherited from class com.northconcepts.datapipeline.foundations.core.FoundationObject
assertValid, clone, exception, exception, exception, getInternalId, getInternalName, resetInternalIdMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.northconcepts.datapipeline.core.DataExceptionContributor
addExceptionProperties
-
Constructor Details
-
CalculatedField
public CalculatedField() -
CalculatedField
Creates a field that is not included in the outcome. -
CalculatedField
-
-
Method Details
-
getVariable
Returns the name of the expression-context variable that receives the expression's result. -
setVariable
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
Returns the expression's source text, ornullif none is set. -
setExpression
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 underfieldsin the decision outcome (default is false). -
setIncludeInOutcome
Indicates if this field's definition (variable and expression, not its value) is listed underfieldsin the decision outcome (default is false). -
assertValid
Description copied from class:FoundationObjectThrows aDataExceptionif this object is invalid, otherwise returns it; the base implementation checks nothing.- Overrides:
assertValidin classFoundationObject
-
evaluate
public void evaluate(DefaultExpressionContext expressionContext) Evaluates the expression in the given context and stores the result there under the variable name; throws aDataExceptionif this field is invalid or the evaluation fails. -
addExceptionProperties
Description copied from class:FoundationObjectAdds this object's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Specified by:
addExceptionPropertiesin interfaceDataExceptionContributor- Overrides:
addExceptionPropertiesin classFoundationObject
-
toRecord
Description copied from interface:RecordSerializableConverts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.- Specified by:
toRecordin interfaceRecordSerializable- Overrides:
toRecordin classBean
-
fromRecord
Description copied from interface:RecordSerializableLoads this instance's state from a record and returnsthis(for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.- Specified by:
fromRecordin interfaceRecordSerializable- Overrides:
fromRecordin classBean- Parameters:
source-- Returns:
- this instance.
-
toXmlElement
Description copied from interface:XmlSerializableReturns an element, created withdocument, describing this object; the default implementation throws aDataException. -
fromXmlElement
-