public interface ContractEnvironment
Methods that match multiple classes accept patterns. Patterns
are semi-qualified names (nested classes have their names
flattened), optionally followed by .*. A normal pattern
matches itself exactly. A star pattern matches any class whose name
begins with the pattern minus the terminating .*. In case
of pattern overlap, subsequent rules override previous ones.
| Modifier and Type | Method and Description |
|---|---|
void |
disableInvariants(java.lang.String pattern)
Disables invariant checking for classes matched by pattern
pattern. |
void |
disablePostconditions(java.lang.String pattern)
Disables postcondition checking for classes matched by pattern
pattern. |
void |
disablePreconditions(java.lang.String pattern)
Disables precondition checking for classes matched by pattern
pattern. |
void |
enableInvariants(java.lang.String pattern)
Enables invariant checking for classes matched by pattern
pattern. |
void |
enablePostconditions(java.lang.String pattern)
Enables postcondition checking for classes matched by pattern
pattern. |
void |
enablePreconditions(java.lang.String pattern)
Enables precondition checking for classes matched by pattern
pattern. |
boolean |
hasInvariantsEnabled(java.lang.Class<?> clazz)
Returns
true if clazz has invariants
enabled. |
boolean |
hasInvariantsEnabled(java.lang.String pattern)
Returns
true if all classes matched by pattern
have invariants enabled. |
boolean |
hasPostconditionsEnabled(java.lang.Class<?> clazz)
Returns
true if clazz has postconditions
enabled. |
boolean |
hasPostconditionsEnabled(java.lang.String pattern)
Returns
true if all classes matched by pattern
have postconditions enabled. |
boolean |
hasPreconditionsEnabled(java.lang.Class<?> clazz)
Returns
true if clazz has preconditions
enabled. |
boolean |
hasPreconditionsEnabled(java.lang.String pattern)
Returns
true if all classes matched by pattern
have preconditions enabled. |
void |
ignore(java.lang.String pattern)
Ignores classes matched by
pattern. |
boolean |
isIgnored(java.lang.String pattern)
Returns
true if all classes matched by pattern
are ignored. |
void |
unignore(java.lang.String pattern)
Unignore classes matched by
pattern. |
@Requires(value="pattern != null") @Ensures(value="hasPreconditionsEnabled(pattern)") void enablePreconditions(java.lang.String pattern)
pattern.java.lang.UnsupportedOperationException - if this environment does
not support selective contract activation@Requires(value="pattern != null") @Ensures(value="!hasPreconditionsEnabled(pattern)") void disablePreconditions(java.lang.String pattern)
pattern.java.lang.UnsupportedOperationException - if this environment does
not support selective contract activation@Requires(value="pattern != null") @Ensures(value="hasPostconditionsEnabled(pattern)") void enablePostconditions(java.lang.String pattern)
pattern.java.lang.UnsupportedOperationException - if this environment does
not support selective contract activation@Requires(value="pattern != null") @Ensures(value="!hasPostconditionsEnabled(pattern)") void disablePostconditions(java.lang.String pattern)
pattern.java.lang.UnsupportedOperationException - if this environment does
not support selective contract activation@Requires(value="pattern != null") @Ensures(value="hasInvariantsEnabled(pattern)") void enableInvariants(java.lang.String pattern)
pattern.java.lang.UnsupportedOperationException - if this environment does
not support selective contract activation@Requires(value="pattern != null") @Ensures(value="!hasInvariantsEnabled(pattern)") void disableInvariants(java.lang.String pattern)
pattern.java.lang.UnsupportedOperationException - if this environment does
not support selective contract activation@Requires(value="clazz != null") boolean hasPreconditionsEnabled(java.lang.Class<?> clazz)
true if clazz has preconditions
enabled. This does not imply that such a class has any
preconditions at all.@Requires(value="pattern != null") boolean hasPreconditionsEnabled(java.lang.String pattern)
true if all classes matched by pattern
have preconditions enabled. This does not imply that
such a class has any preconditions at all.@Requires(value="clazz != null") boolean hasPostconditionsEnabled(java.lang.Class<?> clazz)
true if clazz has postconditions
enabled. This does not imply that such a class has any
postconditions at all.@Requires(value="pattern != null") boolean hasPostconditionsEnabled(java.lang.String pattern)
true if all classes matched by pattern
have postconditions enabled. This does not imply that
such a class has any postconditions at all.@Requires(value="clazz != null") boolean hasInvariantsEnabled(java.lang.Class<?> clazz)
true if clazz has invariants
enabled. This does not imply that such a class has any
invariants at all.@Requires(value="pattern != null") boolean hasInvariantsEnabled(java.lang.String pattern)
true if all classes matched by pattern
have invariants enabled. This does not imply that such a
class has any invariants at all.@Requires(value="pattern != null") @Ensures(value="isIgnored(pattern)") void ignore(java.lang.String pattern)
pattern. Ignored classes are
not touched by Contracts for Java in any way: they are neither
loaded nor examined for contracts.
If you are looking for a method to disable contracts, this is
not the right method; use methods such as
disableInvariants(String) instead.
By default, the following classes are ignored:
java.*
javax.*
com.sun.*
sun.*
@Requires(value="pattern != null") @Ensures(value="!isIgnored(pattern)") void unignore(java.lang.String pattern)
pattern. This method can be
used to unignore some classes that have previously been ignored,
or that are ignored by default.ignore(String)@Requires(value="pattern != null") boolean isIgnored(java.lang.String pattern)
true if all classes matched by pattern
are ignored.ignore(String)