Class DecisionTableRule
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.DecisionTableRule
- All Implemented Interfaces:
DataExceptionContributor,JsonSerializable,RecordSerializable,XmlSerializable,Serializable,Cloneable
A rule of a
DecisionTable that fires when all its conditions hold, setting the result fields with its outcomes.- 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 TypeMethodDescriptionaddCondition(DecisionTableCondition condition) addCondition(String expression) Adds a condition without a variable, so its expression should not use the?placeholder.addCondition(String variable, String expression) Adds a condition whose expression can use?forvariable, as in? > 0.addCondition(Collection<DecisionTableCondition> conditions) addExceptionProperties(DataException exception) Adds this object's current state to aDataException.addOutcome(DecisionTableOutcome outcome) addOutcome(String variable, String expression) Adds an outcome that setsvariableto the value ofexpressionwhen the rule fires.addOutcome(Collection<DecisionTableOutcome> outcomes) Throws aDataExceptionif this object is invalid, otherwise returns it; the base implementation checks nothing.clone()protected booleanevaluate(ExpressionContext expressionContext) Validates the rule and returns true if all its conditions hold in the given context.protected voidevaluateOutcome(ExpressionContext expressionContext, Record record) Evaluates each outcome into the given record; called when the rule fires.fromRecord(Record source) Loads this instance's state from a record and returnsthis(for fluid API call chaining).fromXmlElement(Element element) getName()booleanIndicates if the rule may have no conditions, in which case it always fires; otherwise validation fails (default false).booleanIndicates if the rule may have no outcomes; otherwise validation fails (default false).setAllowNoConditions(boolean allowNoConditions) Indicates if the rule may have no conditions, in which case it always fires; otherwise validation fails (default false).setAllowNoOutcomes(boolean allowNoOutcomes) Indicates if the rule may have no outcomes; otherwise validation fails (default false).setDescription(String description) 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, 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
-
DecisionTableRule
public DecisionTableRule()
-
-
Method Details
-
getName
-
setName
-
getDescription
-
setDescription
-
getConditions
-
addCondition
-
addCondition
-
addCondition
Adds a condition whose expression can use?forvariable, as in? > 0. -
addCondition
Adds a condition without a variable, so its expression should not use the?placeholder. -
getOutcomes
-
addOutcome
-
addOutcome
-
addOutcome
Adds an outcome that setsvariableto the value ofexpressionwhen the rule fires. -
isAllowNoConditions
public boolean isAllowNoConditions()Indicates if the rule may have no conditions, in which case it always fires; otherwise validation fails (default false). -
setAllowNoConditions
Indicates if the rule may have no conditions, in which case it always fires; otherwise validation fails (default false). -
isAllowNoOutcomes
public boolean isAllowNoOutcomes()Indicates if the rule may have no outcomes; otherwise validation fails (default false). -
setAllowNoOutcomes
Indicates if the rule may have no outcomes; otherwise validation fails (default false). -
assertValid
Description copied from class:FoundationObjectThrows aDataExceptionif this object is invalid, otherwise returns it; the base implementation checks nothing.- Overrides:
assertValidin classFoundationObject
-
evaluate
protected boolean evaluate(ExpressionContext expressionContext) Validates the rule and returns true if all its conditions hold in the given context. -
evaluateOutcome
Evaluates each outcome into the given record; called when the rule 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
-
clone
- Overrides:
clonein 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.- Specified by:
toXmlElementin interfaceXmlSerializable
-
fromXmlElement
- Specified by:
fromXmlElementin interfaceXmlSerializable
-