public final class Ensure extends Object
Note: the static methods provided by this class use a fluent interface, i.e., in order to verify an assertion a method sequence needs to be called.
Available checks:Ensure.that(condition).isTrue(); Ensure.that(string).isNotEmpty(); Ensure.that(element).isNotNull(); Ensure.that(array).isNotEmpty(); Ensure.that(collection).isNotNull(); | Modifier and Type | Class and Description |
|---|---|
static class |
Ensure.ArrayCondition
Assertions for arrays.
|
static class |
Ensure.BooleanCondition
Assertions for booleans.
|
static class |
Ensure.CollectionCondition
Assertions for iterables.
|
static class |
Ensure.ExceptionCondition
Assertions for exceptions.
|
static class |
Ensure.IterableCondition
Assertions for iterables.
|
static class |
Ensure.ObjectCondition
Assertions for objects.
|
static class |
Ensure.StringCondition
Assertions for strings.
|
| Modifier and Type | Method and Description |
|---|---|
static Ensure.BooleanCondition |
that(boolean value)
Returns a boolean condition.
|
static Ensure.CollectionCondition |
that(Collection<?> value)
Returns a collection condition.
|
static Ensure.IterableCondition |
that(Iterable<?> value)
Returns an iterable condition.
|
static Ensure.ArrayCondition |
that(Object[] value)
Returns an array condition.
|
static Ensure.ObjectCondition |
that(Object value,
Object... additionalValues)
Returns an object condition.
|
static Ensure.StringCondition |
that(String value)
Returns a string condition.
|
static Ensure.ExceptionCondition |
that(Throwable value)
Returns an exception condition.
|
static void |
thatStatementIsNeverReached()
Always throws an
AssertionError. |
static void |
thatStatementIsNeverReached(String explanation,
Object... args)
Always throws an
AssertionError. |
public static Ensure.BooleanCondition that(boolean value)
value - the value to checkpublic static Ensure.ObjectCondition that(@CheckForNull Object value, @CheckForNull Object... additionalValues)
value - the value to checkadditionalValues - the additional values to checkpublic static Ensure.IterableCondition that(@CheckForNull Iterable<?> value)
value - the value to checkpublic static Ensure.CollectionCondition that(@CheckForNull Collection<?> value)
value - the value to checkpublic static Ensure.ArrayCondition that(@CheckForNull Object[] value)
value - the value to checkpublic static Ensure.StringCondition that(@CheckForNull String value)
value - the value to checkpublic static Ensure.ExceptionCondition that(@CheckForNull Throwable value)
value - the value to checkpublic static void thatStatementIsNeverReached()
AssertionError.@FormatMethod public static void thatStatementIsNeverReached(String explanation, Object... args)
AssertionError.explanation - a formatted message explaining the assertionargs - Arguments referenced by the format specifiers in the formatted explanation. If there are more arguments
than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be
zero.Copyright © 2018. All rights reserved.