java.lang.Object
com.renomad.minum.utils.Invariants
Utilities for asserting invariants within the code.
The purpose here is to make firm statements about the code. This is to help document the code, (e.g. at this point, x is the sum of the ...), to include testing mindset in the code, and to guard against adding bugs during maintenance.
The purpose here is to make firm statements about the code. This is to help document the code, (e.g. at this point, x is the sum of the ...), to include testing mindset in the code, and to guard against adding bugs during maintenance.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
mustBeFalse
(boolean predicate, String message) Specify something which must be falsestatic void
mustBeTrue
(boolean predicate, String message) Specify something which must be true.static <T> T
mustNotBeNull
(T object) specifies that the parameter must be not null.
-
Method Details
-
mustBeTrue
Specify something which must be true.Throws an
InvariantException
if false- Parameters:
predicate
- the boolean expression that must be true at this pointmessage
- a message that will be included in the exception if this is false
-
mustBeFalse
Specify something which must be falseThrows an
InvariantException
if true- Parameters:
predicate
- the boolean expression that must be false at this pointmessage
- a message that will be included in the exception if this is true
-
mustNotBeNull
public static <T> T mustNotBeNull(T object) specifies that the parameter must be not null.Throws an
InvariantException
if null.- Returns:
- the object if not null
-