public class Preconditions
extends java.lang.Object
| Constructor and Description |
|---|
Preconditions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.Collection<T> |
checkNotEmpty(java.util.Collection<T> collection,
java.lang.String errorMessage)
Ensures a collection is neither null nor empty.
|
static <T> T |
checkNotNull(T value,
java.lang.String errorMessage)
Ensures the value is not null.
|
static void |
checkState(boolean expression,
java.lang.String errorMessage)
Ensures the truth of an expression involving the state of the calling
instance, but not involving any parameters to the calling method.
|
public static void checkState(boolean expression,
@Nonnull
java.lang.String errorMessage)
expression - a boolean expressionerrorMessage - error message thrown if expression is false.java.lang.IllegalStateException - if expression is false@Nonnull
public static <T> T checkNotNull(T value,
@Nonnull
java.lang.String errorMessage)
T - type of value.value - value to be validated.errorMessage - error message thrown if value is null.@Nonnull
public static <T> java.util.Collection<T> checkNotEmpty(java.util.Collection<T> collection,
@Nonnull
java.lang.String errorMessage)
T - type of the collection item.collection - collection to be validated.errorMessage - error message to be thrown if collection is null or empty.