Class DecisionTable
java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.core.FoundationObject
com.northconcepts.datapipeline.foundations.decisiontable.DecisionTableObject
com.northconcepts.datapipeline.foundations.decisiontable.DecisionTable
- All Implemented Interfaces:
DataExceptionContributor,JsonSerializable,RecordSerializable,XmlSerializable,Serializable
Evaluates rules in order against a record and returns the outcomes of the first rule whose conditions all hold, or the
default outcomes if none does.
- 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDefaultOutcome(DecisionTableOutcome outcome) Adds an outcome used when no rule fires.addDefaultOutcome(String variable, String expression) Adds an outcome, used when no rule fires, that setsvariableto the value ofexpression.addDefaultOutcome(Collection<DecisionTableOutcome> outcomes) Adds outcomes used when no rule fires.addExceptionProperties(DataException exception) Adds this object's current state to aDataException.addField(CalculatedField field) Adds a calculated field, evaluated before the rules and available to them as a variable.Adds a calculated field that setsvariableto the value ofexpressionbefore the rules are evaluated.addField(Collection<CalculatedField> fields) Adds calculated fields, evaluated before the rules and available to them as variables.addRule(DecisionTableRule rule) Adds a rule after the existing ones; only the first rule whose conditions all hold fires.addRule(Collection<DecisionTableRule> rules) Adds rules after the existing ones; only the first rule whose conditions all hold fires.Throws aDataExceptionif this object is invalid, otherwise returns it; the base implementation checks nothing.evaluate(ExpressionContext expressionContext) Evaluates the calculated fields, then the rules in order, and returns the first rule that fires with its outcome, or the default outcomes if none fires.Loads this object's state from the given JSON text.fromRecord(Record source) Loads this instance's state from a record and returnsthis(for fluid API call chaining).fromXml(InputStream inputStream) Parses the XML in the stream and loads this object's state from its root element.fromXmlElement(Element element) Returns the outcomes used when no rule fires.Returns the calculated fields, evaluated in order before the rules and available to them as variables.getName()DefaultExpressionContextReturns the context holding the constants set withsetValue(String, Object).longReturns the current row number, incremented for each evaluation and available to expressions asrownum.getRules()Returns the rules, evaluated in order until one fires.setDescription(String description) Adds a constant that the table's field, condition and outcome expressions can use.Adds a constant of the given type that the table's field, condition and outcome expressions can use.toRecord()Converts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.Writes this object as indented XML, without a declaration, to the writer and then closes it.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
addExceptionPropertiesMethods inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
fromJson, toJson, toJson, toJson
-
Constructor Details
-
DecisionTable
public DecisionTable()
-
-
Method Details
-
getName
-
setName
-
getDescription
-
setDescription
-
getRootExpressionContext
public DefaultExpressionContext getRootExpressionContext()Returns the context holding the constants set withsetValue(String, Object). -
setValue
Adds a constant that the table's field, condition and outcome expressions can use. -
setValue
Adds a constant of the given type that the table's field, condition and outcome expressions can use. -
getFields
Returns the calculated fields, evaluated in order before the rules and available to them as variables. -
addField
Adds a calculated field, evaluated before the rules and available to them as a variable. -
addField
Adds a calculated field that setsvariableto the value ofexpressionbefore the rules are evaluated. -
addField
-
addField
Adds calculated fields, evaluated before the rules and available to them as variables. -
getRules
Returns the rules, evaluated in order until one fires. -
addRule
Adds a rule after the existing ones; only the first rule whose conditions all hold fires. -
addRule
Adds rules after the existing ones; only the first rule whose conditions all hold fires. -
getRownum
public long getRownum()Returns the current row number, incremented for each evaluation and available to expressions asrownum. -
getDefaultOutcomes
Returns the outcomes used when no rule fires. -
addDefaultOutcome
Adds an outcome used when no rule fires. -
addDefaultOutcome
Adds outcomes used when no rule fires. -
addDefaultOutcome
Adds an outcome, used when no rule fires, that setsvariableto the value ofexpression. -
assertValid
Description copied from class:FoundationObjectThrows aDataExceptionif this object is invalid, otherwise returns it; the base implementation checks nothing.- Overrides:
assertValidin classFoundationObject
-
evaluate
Evaluates the calculated fields, then the rules in order, and returns the first rule that fires with its outcome, or the default outcomes if none fires. -
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
-
toXml
Description copied from interface:XmlSerializableWrites this object as indented XML, without a declaration, to the writer and then closes it. -
fromXml
Description copied from interface:XmlSerializableParses the XML in the stream and loads this object's state from its root element. -
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.
-
fromJson
Description copied from interface:JsonSerializableLoads this object's state from the given JSON text. -
toXmlElement
Description copied from interface:XmlSerializableReturns an element, created withdocument, describing this object; the default implementation throws aDataException. -
fromXmlElement
-