public class OperationSpecification
extends java.lang.Object
java.lang.reflect.AccessibleObject
for the operation, and lists of Precondition
, Postcondition
, and ThrowsCondition
objects that describe contracts on the operation.
Method SpecificationCollection.create(java.util.List)
reads
specifications from JSON files. A user specifies JSON files using the --specifications
command-line option. The JSON should include a JSON object labeled by the name of each field of
this class, as in
{
"operation": {
"classname": "net.Connection",
"name": "send",
"parameterTypes": [
"int"
]
},
"identifiers": {
"parameters": [
"signalValue"
],
"receiverName": "receiver",
"returnName": "result"
},
"pre": [
{
"description": "the signalValue must be positive",
"guard": {
"conditionText": "signalValue > 0"
,
"description": "the signalValue must be positive"
}
}
],
"post": [],
"throws": [],
}
Method SpecificationCollection.getExecutableSpecification(java.lang.reflect.Executable)
translates specifications to an ExecutableSpecification
object that
allows the underlying Boolean expressions to be evaluated.Modifier and Type | Field and Description |
---|---|
private Identifiers |
identifiers
The identifier names used in the specifications.
|
private OperationSignature |
operation
The reflection object for the operation.
|
private java.util.List<Postcondition> |
postSpecifications
The list of post-conditions for the operation.
|
private java.util.List<Precondition> |
preSpecifications
The list of pre-conditions for the operation.
|
private java.util.List<ThrowsCondition> |
throwsSpecifications
The specification of expected exceptions for the operation.
|
Modifier | Constructor and Description |
---|---|
private |
OperationSpecification()
Gson serialization requires a no-argument constructor.
|
|
OperationSpecification(OperationSignature operation,
Identifiers identifiers)
Creates an
OperationSpecification for the given operation with no specifications. |
|
OperationSpecification(OperationSignature operation,
Identifiers identifiers,
java.util.List<Precondition> preSpecifications,
java.util.List<Postcondition> postSpecifications,
java.util.List<ThrowsCondition> throwsSpecifications)
Creates an
OperationSpecification for the given operation with the given
specifications. |
Modifier and Type | Method and Description |
---|---|
void |
addParamSpecifications(java.util.List<Precondition> specifications)
Adds
Precondition objects from the list to this OperationSpecification . |
void |
addReturnSpecifications(java.util.List<Postcondition> specifications)
Adds
Postcondition objects from the list to this OperationSpecification . |
void |
addThrowsConditions(java.util.List<ThrowsCondition> specifications)
Adds
ThrowsCondition objects from the list to this OperationSpecification . |
boolean |
equals(@Nullable java.lang.Object object) |
Identifiers |
getIdentifiers()
Return the
Identifiers for this specification. |
OperationSignature |
getOperation()
Return the
OperationSignature for the operation. |
java.util.List<Postcondition> |
getPostconditions()
Return the list of
Postcondition objects for this OperationSpecification . |
java.util.List<Precondition> |
getPreconditions()
Return the list of
Precondition objects for this OperationSpecification . |
java.util.List<ThrowsCondition> |
getThrowsConditions()
Return the list of
ThrowsCondition objects for this OperationSpecification . |
int |
hashCode() |
boolean |
isEmpty()
Indicates whether this
OperationSpecification contains any pre-, post-, or
throws-specifications. |
java.lang.String |
toString() |
private final OperationSignature operation
private final Identifiers identifiers
@SerializedName(value="pre") private final java.util.List<Precondition> preSpecifications
@SerializedName(value="post") private final java.util.List<Postcondition> postSpecifications
@SerializedName(value="throws") private final java.util.List<ThrowsCondition> throwsSpecifications
private OperationSpecification()
public OperationSpecification(OperationSignature operation, Identifiers identifiers)
OperationSpecification
for the given operation with no specifications.operation
- the OperationSignature
object, must be non-nullidentifiers
- the Identifiers
object, must be non-nullpublic OperationSpecification(OperationSignature operation, Identifiers identifiers, java.util.List<Precondition> preSpecifications, java.util.List<Postcondition> postSpecifications, java.util.List<ThrowsCondition> throwsSpecifications)
OperationSpecification
for the given operation with the given
specifications.operation
- the reflection object for the operation, must be non-nullidentifiers
- the identifiers used in the specificationspreSpecifications
- the list of param specifications for the operationpostSpecifications
- the list of return specifications for the operationthrowsSpecifications
- the list of specifications for the operationpublic OperationSignature getOperation()
OperationSignature
for the operation.public Identifiers getIdentifiers()
Identifiers
for this specification.public java.util.List<Precondition> getPreconditions()
Precondition
objects for this OperationSpecification
.Precondition
objects for this specificationpublic java.util.List<Postcondition> getPostconditions()
Postcondition
objects for this OperationSpecification
.Postcondition
objects for this specificationpublic java.util.List<ThrowsCondition> getThrowsConditions()
ThrowsCondition
objects for this OperationSpecification
.public void addParamSpecifications(java.util.List<Precondition> specifications)
Precondition
objects from the list to this OperationSpecification
.specifications
- the list of Precondition
objectspublic void addReturnSpecifications(java.util.List<Postcondition> specifications)
Postcondition
objects from the list to this OperationSpecification
.specifications
- the list of Postcondition
objectspublic void addThrowsConditions(java.util.List<ThrowsCondition> specifications)
ThrowsCondition
objects from the list to this OperationSpecification
.specifications
- the list of ThrowsCondition
objectspublic boolean isEmpty()
OperationSpecification
contains any pre-, post-, or
throws-specifications.true
if there are no pre-, post-, or throws-specifications, false otherwisepublic boolean equals(@Nullable java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object