public class ExecutableSpecification
extends java.lang.Object
OperationSpecification. It
allows the underlying Boolean expressions to be evaluated.
It is represented as three collections: a collection of ExecutableBooleanExpression
for the Precondition, a collection of GuardPropertyPair for the Postcondition, and a
collection of GuardThrowsPair for the ThrowsCondition in a specification.
It includes specifications inherited from supertypes.
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<GuardPropertyPair> |
guardPropertyPairs
The
GuardThrowsPair objects for the Postconditions of the operation. |
private java.util.List<GuardThrowsPair> |
guardThrowsPairs
The
GuardThrowsPair objects for the ThrowsConditions of the operation. |
private java.util.List<ExecutableSpecification> |
parentList
Mirrors the overrides/implements relation among methods.
|
private java.util.List<ExecutableBooleanExpression> |
preExpressions
The
ExecutableBooleanExpression objects for the Preconditions of the operation. |
| Constructor and Description |
|---|
ExecutableSpecification()
Creates an empty
ExecutableSpecification object. |
ExecutableSpecification(java.util.List<ExecutableBooleanExpression> preExpressions,
java.util.List<GuardPropertyPair> guardPropertyPairs,
java.util.List<GuardThrowsPair> guardThrowsPairs)
Creates an
ExecutableSpecification object for the lists of guard expressions for
pre-specifications, GuardPropertyPair objects for post-specifications, and GuardThrowsPair objects for throws-specifications. |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addParent(ExecutableSpecification parentExecSpec)
Add the parent
ExecutableSpecification for this collection. |
private @Nullable ExecutableBooleanExpression |
checkGuardPropertyPairs(java.lang.Object[] args)
Tests the given argument values against the guards of local postconditions, which are the
GuardPropertyPair objects in this ExecutableSpecification. |
private java.util.List<ThrowsClause> |
checkGuardThrowsPairs(java.lang.Object[] args)
Evaluate the guard of each local
GuardThrowsPair, and for each one satisfied, add the
ThrowsClause to the set of expected exceptions. |
private boolean |
checkPreExpressions(java.lang.Object[] args)
Tests the given argument values against the local preconditions, which are the
ExecutableBooleanExpression objects in preExpressions in this ExecutableSpecification. |
ExpectedOutcomeTable |
checkPrestate(java.lang.Object[] args)
Check all guard expressions of the method's full specification, which includes this
ExecutableSpecification and those of any overridden/implemented method. |
private void |
checkPrestate(java.lang.Object[] args,
ExpectedOutcomeTable table)
Modifies the given table, adding an
ExpectedOutcomeTable entry for the guard
expressions of this method's local specification recording the following:
Whether the preExpressions fail or are satisfied. |
boolean |
isEmpty()
Indicates whether the full specification is empty: this
ExecutableSpecification, and
any member of the parent list, has no guard expresions, no property pairs, and no throws pairs. |
static ExecutableSpecification |
merge(ExecutableSpecification spec1,
ExecutableSpecification spec2)
Merges two ExecutableSpecifications into a new one that contains the union of their components.
|
java.lang.String |
toString() |
private final java.util.List<ExecutableBooleanExpression> preExpressions
ExecutableBooleanExpression objects for the Preconditions of the operation.private final java.util.List<GuardPropertyPair> guardPropertyPairs
GuardThrowsPair objects for the Postconditions of the operation.private final java.util.List<GuardThrowsPair> guardThrowsPairs
GuardThrowsPair objects for the ThrowsConditions of the operation.private java.util.List<ExecutableSpecification> parentList
parentList contains one element for
each method that m overrides or implements (and has specifications).public ExecutableSpecification()
ExecutableSpecification object.public ExecutableSpecification(java.util.List<ExecutableBooleanExpression> preExpressions, java.util.List<GuardPropertyPair> guardPropertyPairs, java.util.List<GuardThrowsPair> guardThrowsPairs)
ExecutableSpecification object for the lists of guard expressions for
pre-specifications, GuardPropertyPair objects for post-specifications, and GuardThrowsPair objects for throws-specifications.preExpressions - the operation pre-specificationsguardPropertyPairs - the operation post-specificationsguardThrowsPairs - the operation throws-specificationspublic ExpectedOutcomeTable checkPrestate(java.lang.Object[] args)
ExecutableSpecification and those of any overridden/implemented method.args - the argument values to test the guard expressions; always includes a receiver (null
for static methods)checkPrestate(Object[], ExpectedOutcomeTable)private void checkPrestate(java.lang.Object[] args,
ExpectedOutcomeTable table)
ExpectedOutcomeTable entry for the guard
expressions of this method's local specification recording the following:
preExpressions fail or are satisfied. See checkPreExpressions(java.lang.Object[]).
ThrowsClause objects for expected exceptions. See checkGuardThrowsPairs(java.lang.Object[]).
ExecutableBooleanExpression, if any. See checkGuardPropertyPairs(java.lang.Object[]).
args - the argument values; always includes a receiver (null for static methods)table - the table to which the created entry is to be addedprivate boolean checkPreExpressions(java.lang.Object[] args)
ExecutableBooleanExpression objects in preExpressions in this ExecutableSpecification.args - the argument valuesprivate java.util.List<ThrowsClause> checkGuardThrowsPairs(java.lang.Object[] args)
GuardThrowsPair, and for each one satisfied, add the
ThrowsClause to the set of expected exceptions.args - the argument valuesprivate @Nullable ExecutableBooleanExpression checkGuardPropertyPairs(java.lang.Object[] args)
GuardPropertyPair objects in this ExecutableSpecification. Returns the ExecutableBooleanExpression from the first pair whose guard expression evaluated to true.args - the argument valuesGuardPropertyPair for which the guard expression
evaluates to true; null if there is nonepublic static ExecutableSpecification merge(ExecutableSpecification spec1, ExecutableSpecification spec2)
spec1 - the first ExecutableSpecification to mergespec2 - the second ExecutableSpecification to mergevoid addParent(ExecutableSpecification parentExecSpec)
ExecutableSpecification for this collection.parentExecSpec - the ExecutableSpecification to which to linkpublic boolean isEmpty()
ExecutableSpecification, and
any member of the parent list, has no guard expresions, no property pairs, and no throws pairs.public java.lang.String toString()
toString in class java.lang.Object