public final class Preconditions extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ARGUMENT_EMPTY |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean expression,
String errorMessageTemplate,
Object... errorMessageArgs)
Ensures the truth of an expression involving one or more parameters to the calling method.
|
static <T> void |
checkNotNull(FilterOperator<T> filterOperator)
Verifies that the given
FilterOperator reference is not null. |
static <T> T |
checkNotNull(T reference)
Verifies that the given object reference is not
null. |
static <T> T |
checkNotNull(T reference,
String message)
Verifies that the given object reference is not
null. |
static CharSequence |
checkNotNullOrEmpty(CharSequence s)
Verifies that the given
CharSequence is not null or empty. |
static CharSequence |
checkNotNullOrEmpty(CharSequence s,
String message)
Verifies that the given
CharSequence is not null or empty. |
static <T> T[] |
checkNotNullOrEmpty(T[] array)
Verifies that the given array is not
null or empty. |
static void |
checkState(boolean expression,
String errorMessageTemplate,
Object... errorMessageArgs)
Ensures the truth of an expression involving the state of the calling instance, but not
involving any parameters to the calling method.
|
public static final String ARGUMENT_EMPTY
public static CharSequence checkNotNullOrEmpty(CharSequence s)
CharSequence is not null or empty.s - the given CharSequence.CharSequence.NullPointerException - if the given CharSequence is null.IllegalArgumentException - if the given CharSequence is empty.public static CharSequence checkNotNullOrEmpty(CharSequence s, String message)
CharSequence is not null or empty.s - the given CharSequence.message - error message in case of empty String.CharSequence.NullPointerException - if the given CharSequence is null.IllegalArgumentException - if the given CharSequence is empty.public static <T> T[] checkNotNullOrEmpty(T[] array)
null or empty.T - the type of elements of the array.array - the given array.NullPointerException - if the given array is null.IllegalArgumentException - if the given array is empty.public static <T> T checkNotNull(T reference)
null.T - the type of the reference to check.reference - the given object reference.null reference that was validated.NullPointerException - if the given object reference is null.public static <T> T checkNotNull(T reference,
String message)
null.T - the type of the reference to check.reference - the given object reference.message - error message in case of null reference.null reference that was validated.NullPointerException - if the given object reference is null.public static <T> void checkNotNull(FilterOperator<T> filterOperator)
FilterOperator reference is not null.T - the type of the FilterOperator to check.filterOperator - the given FilterOperator reference.IllegalArgumentException - if the given FilterOperator reference is null.public static void checkArgument(boolean expression,
String errorMessageTemplate,
Object... errorMessageArgs)
Borrowed from Guava.
expression - a boolean expressionerrorMessageTemplate - a template for the exception message should the check fail. The
message is formed by calling String.format(String, Object...) with the given parameters.errorMessageArgs - the arguments to be substituted into the message template.IllegalArgumentException - if expression is falseNullPointerException - if the check fails and either errorMessageTemplate or
errorMessageArgs is null (don't let this happen)public static void checkState(boolean expression,
String errorMessageTemplate,
Object... errorMessageArgs)
Borrowed from Guava.
expression - a boolean expressionerrorMessageTemplate - a template for the exception message should the check fail.The
message is formed by calling String.format(String, Object...) with the given parameters.errorMessageArgs - the arguments to be substituted into the message template. Arguments
are converted to strings using String.valueOf(Object).IllegalStateException - if expression is falseNullPointerException - if the check fails and either errorMessageTemplate or
errorMessageArgs is null (don't let this happen)Copyright © 2014–2019 AssertJ. All rights reserved.