public final class Preconditions extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
checkNotNull(T reference)
Ensures that an object reference passed as a parameter to the calling method is not null.
|
static void |
checkState(boolean expression)
Ensures the truth of an expression involving the state of the calling instance.
|
static void |
checkState(boolean expression,
Object errorMessage)
Ensures the truth of an expression involving the state of the calling instance.
|
public static <T> T checkNotNull(T reference)
reference - an object referenceNullPointerException - if reference is nullpublic static void checkState(boolean expression)
expression - a boolean expression that must be checked to be trueIllegalStateException - if expression is falsepublic static void checkState(boolean expression,
@Nullable
Object errorMessage)
expression - a boolean expression that must be checked to be trueerrorMessage - the exception message to use if the check fails; will be converted to a
string using String.valueOf(Object)IllegalStateException - if expression is false