-
- All Implemented Interfaces:
public class Assert
-
-
Method Summary
Modifier and Type Method Description static <T> voidnonNull(T expression, String message)static voidstate(boolean state, Supplier<String> messageSupplier)Asserts that the value of stateis true.static voidisTrue(boolean expression, Supplier<String> messageSupplier)Asserts that the given expressionis true.static voidisFalse(boolean expression, Supplier<String> messageSupplier)Asserts that the given expressionis false.static voidnotNull(Object value, Supplier<String> messageSupplier)Assert that the given valueis notnull.static <T> TnonNull(T value, Supplier<String> messageSupplier)Assert that the given valueis notnull.static <T, X extends Throwable> voidassertThat(T value, Predicate<T> assertion, Supplier<out X> exceptionSupplier)Assert that the given valuewill result totruethrough theassertionPredicate.static <T, X extends Throwable> voidassertNonNull(T value, Supplier<out X> exceptionSupplier)Assert that the given valueis non null.-
-
Method Detail
-
state
static void state(boolean state, Supplier<String> messageSupplier)
Asserts that the value of
stateis true. If not, an IllegalStateException is thrown.- Parameters:
state- the state validation expressionmessageSupplier- Supplier of the exception message if state evaluates to false
-
isTrue
static void isTrue(boolean expression, Supplier<String> messageSupplier)
Asserts that the given
expressionis true. If not, an IllegalArgumentException is thrown.- Parameters:
expression- the state validation expressionmessageSupplier- Supplier of the exception message if the expression evaluates to false
-
isFalse
static void isFalse(boolean expression, Supplier<String> messageSupplier)
Asserts that the given
expressionis false. If not, an IllegalArgumentException is thrown.- Parameters:
expression- the state validation expressionmessageSupplier- Supplier of the exception message if the expression evaluates to true
-
notNull
static void notNull(Object value, Supplier<String> messageSupplier)
Assert that the given
valueis notnull. If not, an IllegalArgumentException is thrown.- Parameters:
value- the value not to benullmessageSupplier- Supplier of the exception message if the assertion fails
-
nonNull
static <T> T nonNull(T value, Supplier<String> messageSupplier)
Assert that the given
valueis notnull. If not, an IllegalArgumentException is thrown.- Parameters:
value- the value not to benullmessageSupplier- Supplier of the exception message if the assertion fails
-
assertThat
static <T, X extends Throwable> void assertThat(T value, Predicate<T> assertion, Supplier<out X> exceptionSupplier)
Assert that the given
valuewill result totruethrough theassertionPredicate. If not, theexceptionSupplierprovides an exception to be thrown.
-
assertNonNull
static <T, X extends Throwable> void assertNonNull(T value, Supplier<out X> exceptionSupplier)
Assert that the given
valueis non null. If not, theexceptionSupplierprovides an exception to be thrown.- Parameters:
value- aTspecifying the value to assertexceptionSupplier- a Supplier of the exceptionXifvalueequals null
-
-
-
-