org.conqat.lib.commons.assertion.package.html Maven / Gradle / Ivy
Show all versions of teamscale-lib-commons Show documentation
This package provides support for precondition checking and assertions.
Preconditions vs Assertions
To understand the difference between preconditions and assertions it is
important do differentiate between the developer of a component (class,
method, ...) and the user of this component.
Preconditions are used to signal violations of the usage
contract of components to its user. These preconditions are
usually documented as part of the component's comment.
Examples: "Argument may not
be null
", "Argument must be positive",
"cannot call x
for empty list". Preconditions are checked
using the methods of the {@link org.conqat.lib.commons.assertion.CCSMPre}
class. Violations are signaled with
{@link org.conqat.lib.commons.assertion.PreconditionException}s.
Assertions are used to check that invariants that only the
developer of component knows are valid. These are used to check for
implementation (opposed to usage) faults.
Examples are: "Stack size
cannot be negative.", "Array index must not be greater than array length".
Assertions are checked
using the methods of the {@link org.conqat.lib.commons.assertion.CCSMAssert}
class. Violations are signaled with
{@link java.lang.AssertionError}s.