public abstract class Assert extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T,X extends Throwable> |
assertNonNull(T value,
Supplier<? extends X> exceptionSupplier)
Assert that the given
value is non null. |
static <T,X extends Throwable> |
assertThat(T value,
Predicate<T> assertion,
Supplier<? extends X> exceptionSupplier)
|
static void |
isFalse(boolean expression,
Supplier<String> messageSupplier)
Asserts that the given
expression is false. |
static void |
isTrue(boolean expression,
Supplier<String> messageSupplier)
Asserts that the given
expression is true. |
static <T> T |
nonNull(T value,
Supplier<String> messageSupplier)
Assert that the given
value is not null. |
static void |
notNull(Object value,
Supplier<String> messageSupplier)
Assert that the given
value is not null. |
static void |
state(boolean state,
Supplier<String> messageSupplier)
Asserts that the value of
state is true. |
public static void state(boolean state,
Supplier<String> messageSupplier)
state is true. If not, an IllegalStateException is thrown.state - the state validation expressionmessageSupplier - Supplier of the exception message if state evaluates to falsepublic static void isTrue(boolean expression,
Supplier<String> messageSupplier)
expression is true. If not, an IllegalArgumentException is thrown.expression - the state validation expressionmessageSupplier - Supplier of the exception message if the expression evaluates to falsepublic static void isFalse(boolean expression,
Supplier<String> messageSupplier)
expression is false. If not, an IllegalArgumentException is thrown.expression - the state validation expressionmessageSupplier - Supplier of the exception message if the expression evaluates to truepublic static void notNull(Object value, Supplier<String> messageSupplier)
value is not null. If not, an IllegalArgumentException is
thrown.value - the value not to be nullmessageSupplier - Supplier of the exception message if the assertion failspublic static <T> T nonNull(T value,
Supplier<String> messageSupplier)
value is not null. If not, an IllegalArgumentException is
thrown.value - the value not to be nullmessageSupplier - Supplier of the exception message if the assertion failsvaluepublic static <T,X extends Throwable> void assertThat(T value, Predicate<T> assertion, Supplier<? extends X> exceptionSupplier) throws X extends Throwable
value will result to true through the assertion Predicate.
If not, the exceptionSupplier provides an exception
to be thrown.T - a generic specifying the type of the value, which is the input for the
assertionX - a generic extending Throwable which will be provided by the
exceptionSuppliervalue - a T specifying the value to assertassertion - a Predicate to test value againstexceptionSupplier - a Supplier of the exception X if assertion evaluates to falseX - if the value asserts to false by the assertionX extends Throwablepublic static <T,X extends Throwable> void assertNonNull(T value, Supplier<? extends X> exceptionSupplier) throws X extends Throwable
value is non null. If not, the exceptionSupplier provides an exception to
be thrown.T - a generic specifying the type of the value, which is the input for the
assertionX - a generic extending Throwable which will be provided by the
exceptionSuppliervalue - a T specifying the value to assertexceptionSupplier - a Supplier of the exception X if value equals nullX - if the value equals nullX extends ThrowableCopyright © 2010–2023. All rights reserved.