public class ViolationTracker
extends Object
A violation tracker is used to keep a list of pre-, post-condition or class-invariant violations in chronological order. This is necessary to evaluate all parts of a pre- or postcondition, and still being able to rethrow assertion errors.
| Modifiers | Name | Description |
|---|---|---|
static ThreadLocal<ViolationTracker> |
INSTANCE |
Stores the tracker bound to the current thread while a contract is being evaluated. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static void |
deinit()Removes the tracker associated with the current thread. |
|
public AssertionViolation |
first()Returns the earliest recorded violation. |
|
public boolean |
hasViolations()Indicates whether this tracker currently contains any violations. |
|
public static void |
init()Installs a fresh tracker for the current thread. |
|
public AssertionViolation |
last()Returns the most recently recorded violation. |
|
public static void |
rethrowFirst()Rethrows the earliest recorded violation for the current thread. |
|
public static void |
rethrowLast()Rethrows the most recently recorded violation for the current thread. |
|
public void |
track(AssertionViolation assertionViolation)Records a newly observed assertion violation in encounter order. |
|
public static boolean |
violationsOccurred()Indicates whether the current thread has recorded at least one violation. |
Stores the tracker bound to the current thread while a contract is being evaluated.
Removes the tracker associated with the current thread.
Returns the earliest recorded violation.
Indicates whether this tracker currently contains any violations.
true if at least one violation has been recordedInstalls a fresh tracker for the current thread.
Returns the most recently recorded violation.
Rethrows the earliest recorded violation for the current thread.
Rethrows the most recently recorded violation for the current thread.
Records a newly observed assertion violation in encounter order.
assertionViolation - the violation to storeIndicates whether the current thread has recorded at least one violation.
true if a violation has been tracked for the current thread