Class CandidateChecks
- java.lang.Object
-
- org.apache.groovy.contracts.generation.CandidateChecks
-
public class CandidateChecks extends Object
Functions in this class are used to determine whether a certain AST node fulfills certain assertion requirements. E.g. whether a class node is a class invariant candidate or not.
-
-
Constructor Summary
Constructors Constructor Description CandidateChecks()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
couldBeContractElementMethodNode(ClassNode type, MethodNode method)
Checks whether the givenMethodNode
could be a candidate for an arbitraryContractElement
annotation.static boolean
isClassInvariantCandidate(ClassNode type, MethodNode method)
Decides whether the given method is a candidate for class invariants.static boolean
isClassInvariantCandidate(PropertyNode propertyNode)
Decides whether the given propertyNode is a candidate for class invariant injection.static boolean
isContractsCandidate(ClassNode type)
Checks whether the givenClassNode
is a candidate for applying contracts.static boolean
isInterfaceContractsCandidate(ClassNode type)
Checks whether the givenClassNode
is a candidate for applying interface contracts.static boolean
isPostconditionCandidate(ClassNode type, MethodNode method)
Decides whether the given method is a candidate for a post-condition.static boolean
isPreconditionCandidate(ClassNode type, MethodNode method)
Decides whether the given method is a candidate for a pre-condition.static boolean
isPreOrPostconditionCandidate(ClassNode type, MethodNode method)
Decides whether the given method is a candidate for a pre- or postcondition.static boolean
isRuntimeClass(ClassNode type)
Checks whether the givenClassNode
is part of the Groovy/Java runtime.
-
-
-
Method Detail
-
isContractsCandidate
public static boolean isContractsCandidate(ClassNode type)
Checks whether the givenClassNode
is a candidate for applying contracts.If the given class node has already been processed in this compilation run, this method will return false.
- Parameters:
type
- theClassNode
to be checked- Returns:
- whether the given type is a candidate for applying contract assertions
-
isInterfaceContractsCandidate
public static boolean isInterfaceContractsCandidate(ClassNode type)
Checks whether the givenClassNode
is a candidate for applying interface contracts.- Parameters:
type
- theClassNode
to be checked- Returns:
- whether the given type is a candidate for applying interface contract assertions
-
isClassInvariantCandidate
public static boolean isClassInvariantCandidate(PropertyNode propertyNode)
Decides whether the given propertyNode is a candidate for class invariant injection.- Parameters:
propertyNode
- thePropertyNode
to check- Returns:
- whether the propertyNode is a candidate for injecting the class invariant or not
-
isPreOrPostconditionCandidate
public static boolean isPreOrPostconditionCandidate(ClassNode type, MethodNode method)
Decides whether the given method is a candidate for a pre- or postcondition.- Parameters:
type
- the currentClassNode
method
- theMethodNode
to check for pre- or postcondition compliance- Returns:
- whether the given
MethodNode
is a candidate for pre- or postconditions
-
isClassInvariantCandidate
public static boolean isClassInvariantCandidate(ClassNode type, MethodNode method)
Decides whether the given method is a candidate for class invariants.- Parameters:
type
- the currentClassNode
method
- theMethodNode
to check for class invariant compliance- Returns:
- whether the given
MethodNode
is a candidate for class invariants
-
isPreconditionCandidate
public static boolean isPreconditionCandidate(ClassNode type, MethodNode method)
Decides whether the given method is a candidate for a pre-condition.- Parameters:
type
- the currentClassNode
method
- theMethodNode
to check for pre-condition compliance- Returns:
- whether the given
MethodNode
is a candidate for pre-conditions
-
isPostconditionCandidate
public static boolean isPostconditionCandidate(ClassNode type, MethodNode method)
Decides whether the given method is a candidate for a post-condition.- Parameters:
type
- the currentClassNode
method
- theMethodNode
to check for post-condition compliance- Returns:
- whether the given
MethodNode
is a candidate for post-conditions
-
couldBeContractElementMethodNode
public static boolean couldBeContractElementMethodNode(ClassNode type, MethodNode method)
Checks whether the givenMethodNode
could be a candidate for an arbitraryContractElement
annotation.- Parameters:
type
- the currentClassNode
method
- theMethodNode
to check forContractElement
compliance- Returns:
- whether the given method node could be a candidate or not
-
-