public final class Preconditions
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ARGUMENT_EMPTY |
| Modifier | Constructor and Description |
|---|---|
private |
Preconditions() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.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,
java.lang.String message)
Verifies that the given object reference is not
null. |
static java.lang.CharSequence |
checkNotNullOrEmpty(java.lang.CharSequence s)
Verifies that the given
CharSequence is not null or empty. |
static java.lang.CharSequence |
checkNotNullOrEmpty(java.lang.CharSequence s,
java.lang.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,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
Ensures the truth of an expression involving the state of the calling instance, but not
involving any parameters to the calling method.
|
private static void |
throwExceptionForBeingEmpty() |
private static void |
throwExceptionForBeingEmpty(java.lang.String message) |
public static final java.lang.String ARGUMENT_EMPTY
public static java.lang.CharSequence checkNotNullOrEmpty(java.lang.CharSequence s)
CharSequence is not null or empty.s - the given CharSequence.CharSequence.java.lang.NullPointerException - if the given CharSequence is null.java.lang.IllegalArgumentException - if the given CharSequence is empty.public static java.lang.CharSequence checkNotNullOrEmpty(java.lang.CharSequence s,
java.lang.String message)
CharSequence is not null or empty.s - the given CharSequence.message - error message in case of empty String.CharSequence.java.lang.NullPointerException - if the given CharSequence is null.java.lang.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.java.lang.NullPointerException - if the given array is null.java.lang.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.java.lang.NullPointerException - if the given object reference is null.public static <T> T checkNotNull(T reference,
java.lang.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.java.lang.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.java.lang.IllegalArgumentException - if the given FilterOperator reference is null.public static void checkArgument(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.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.java.lang.IllegalArgumentException - if expression is falsejava.lang.NullPointerException - if the check fails and either errorMessageTemplate or
errorMessageArgs is null (don't let this happen)public static void checkState(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.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).java.lang.IllegalStateException - if expression is falsejava.lang.NullPointerException - if the check fails and either errorMessageTemplate or
errorMessageArgs is null (don't let this happen)private static void throwExceptionForBeingEmpty()
private static void throwExceptionForBeingEmpty(java.lang.String message)