public final class Preconditions
extends java.lang.Object
| Constructor and Description |
|---|
Preconditions() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean condition,
java.lang.String errorMsg)
Checks that the condition is
true. |
static java.lang.String[] |
checkNoneEmpty(java.lang.String[] values,
java.lang.String paramName,
java.lang.String itemName)
Checks that the
values are not empty. |
static int |
checkNotNegative(int value,
java.lang.String paramName)
Checks that the
value is not negative. |
static long |
checkNotNegative(long value,
java.lang.String paramName)
Checks that the
value is not negative. |
static <T> T |
checkNotNull(T value,
java.lang.String paramName)
Checks that the
value is not null. |
static java.lang.String |
checkNotNullOrEmpty(java.lang.String value,
java.lang.String paramName)
Checks that the
value is not empty. |
public static <T> T checkNotNull(T value,
java.lang.String paramName)
value is not null. Returns the value
directly, so you can use checkNotNull(value) inline.T - The type of the value being checked.value - The object to perform the null check.paramName - The name of the parameter that cannot be null.public static java.lang.String checkNotNullOrEmpty(java.lang.String value,
java.lang.String paramName)
value is not empty.value - The object to perform the check on.paramName - The name of the parameter that can't be empty.public static void checkArgument(boolean condition,
java.lang.String errorMsg)
true. Use for validating arguments
to methods.condition - The condition to check.errorMsg - The error message to display if the check was false.public static int checkNotNegative(int value,
java.lang.String paramName)
value is not negative.value - The object to perform the check on.paramName - The name of the parameter that can't be negative.public static long checkNotNegative(long value,
java.lang.String paramName)
value is not negative.value - The object to perform the check on.paramName - The name of the parameter that can't be negative.public static java.lang.String[] checkNoneEmpty(java.lang.String[] values,
java.lang.String paramName,
java.lang.String itemName)
values are not empty.values - The values to check.paramName - The name of the parameter that is to be checked.itemName - The name of an item from the values.