public abstract class StoppingConditionConstraint extends DefinitionalObject
StoppingConditionConstraintEvaluator
. These constraints act as
additional criteria for a StoppingCondition
. The
constraints
will take the current state of propagation
and return a boolean
for if this state is allowed to potentially stop propagation.
Often there are times when a StoppingCondition
needs additional criteria to truly
stop on the desired event. Simply combining StoppingConditions
usually wouldn't work; if you would AND two conditions together, they both must have their own
relevant events at the exact same time. It is more reasonable to add constraints to a stopping
condition that could, instead of stopping at some particular event, could instead signal that some
other event has gone by, or has not happened yet.
See the Stopping Conditions topic for more detail on how to use stopping condition constraints.
Although you can create any constraint as long as it returns true
or false
,
the common use case of computing some single value from the passed in
state
and comparing it to a threshold should
usually be handled by the ThresholdStoppingConditionConstraint
.
Modifier | Constructor and Description |
---|---|
protected |
StoppingConditionConstraint()
Initializes a new instance.
|
protected |
StoppingConditionConstraint(StoppingConditionConstraint existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
protected |
StoppingConditionConstraint(WhenToCheckConstraint whenToCheck)
Initializes a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkForSameDefinition(DefinitionalObject other)
Checks to determine if another instance has the same definition as this instance and
returns
true if it does. |
protected abstract boolean |
checkForSameDefinition(StoppingConditionConstraint other)
Checks to determine if another instance has the same definition as this instance and
returns
true if it does. |
protected int |
computeCurrentDefinitionHashCode()
Computes a hash code based on the current properties of this object.
|
abstract StoppingConditionConstraintEvaluator |
getEvaluator(EvaluatorGroup group)
Gets a
StoppingConditionConstraintEvaluator for use in the
StoppingConditionEvaluator . |
String |
getName()
Gets the optional name of this constraint.
|
WhenToCheckConstraint |
getWhenToCheck()
Gets when to check this constraint (when a stop is detected or found).
|
void |
setName(String value)
Sets the optional name of this constraint.
|
void |
setWhenToCheck(WhenToCheckConstraint value)
Sets when to check this constraint (when a stop is detected or found).
|
areSameDefinition, areSameDefinition, areSameDefinition, areSameDefinition, areSameDefinition, clone, collectionItemsAreSameDefinition, collectionItemsAreSameDefinition, collectionItemsAreSameDefinition, dictionaryItemsAreSameDefinition, enumerateDependencies, freeze, freezeAggregatedObjects, getCollectionHashCode, getCollectionHashCode, getCollectionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDictionaryHashCode, getIsFrozen, isSameDefinition, throwIfFrozen
protected StoppingConditionConstraint()
protected StoppingConditionConstraint(@Nonnull WhenToCheckConstraint whenToCheck)
whenToCheck
- Specifies whether this condition should be checked when a stop is detected or found.protected StoppingConditionConstraint(@Nonnull StoppingConditionConstraint existingInstance, @Nonnull CopyContext context)
See ICloneWithContext.clone(CopyContext)
for more information about how to implement this constructor
in a derived class.
existingInstance
- The existing instance to copy.context
- A CopyContext
that controls the depth of the copy.ArgumentNullException
- Thrown when existingInstance
or context
is null
.protected final boolean checkForSameDefinition(DefinitionalObject other)
true
if it does. Derived classes MUST override this method and check
all new fields introduced by the derived class for definitional equivalence. It is NOT necessary
to check base class fields because the base class will already have done that. When overriding this method,
you should NOT call the base implementation because it will return false
for all derived-class instances.
Derived classes should check the type of other
to preserve the symmetric nature of IEquatableDefinition.isSameDefinition(java.lang.Object)
.checkForSameDefinition
in class DefinitionalObject
other
- The other instance to compare to this one.true
if the two objects are defined equivalently; otherwise false
.protected abstract boolean checkForSameDefinition(StoppingConditionConstraint other)
true
if it does. Derived classes MUST override this method and check
all new fields introduced by the derived class for definitional equivalence. It is NOT necessary
to check base class fields because the base class will already have done that. When overriding this method,
you should NOT call the base implementation because it will return false
for all derived-class instances.
Derived classes should check the type of other
to preserve the symmetric nature of IEquatableDefinition.isSameDefinition(java.lang.Object)
.other
- The other instance to compare to this one.true
if the two objects are defined equivalently; otherwise false
.protected int computeCurrentDefinitionHashCode()
StoppingConditionConstraint.checkForSameDefinition(agi.foundation.infrastructure.DefinitionalObject)
method.computeCurrentDefinitionHashCode
in class DefinitionalObject
public final String getName()
public final void setName(String value)
@Nonnull public final WhenToCheckConstraint getWhenToCheck()
public final void setWhenToCheck(@Nonnull WhenToCheckConstraint value)
@Nonnull public abstract StoppingConditionConstraintEvaluator getEvaluator(@Nonnull EvaluatorGroup group)
StoppingConditionConstraintEvaluator
for use in the
StoppingConditionEvaluator
.group
- The group
to use to initialize any
evaluators
that will be used by actual constraint.evaluator
for this
StoppingConditionConstraint
.