public final class Preconditions
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean expression)
Validates the expression is true.
|
static void |
checkArgument(boolean expression,
java.lang.Object errorMessage)
Validates the expression is true.
|
static void |
checkArgument(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
Validates the expression is true.
|
static <T> T |
checkNotNull(T reference)
Validates the object is not null.
|
static <T> T |
checkNotNull(T reference,
java.lang.Object errorMessage)
Validates the object is not null.
|
static <T> T |
checkNotNull(T reference,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
Validates the object is not null.
|
static void |
checkState(boolean expression)
Ensures the truth of an expression involving the state of the calling instance, but not
involving any parameters to the calling method.
|
static void |
checkState(boolean expression,
java.lang.Object 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 checkArgument(boolean expression)
expression - a boolean expressionjava.lang.IllegalArgumentException - if expression is falsepublic static void checkArgument(boolean expression,
java.lang.Object errorMessage)
expression - a boolean expressionerrorMessage - Error message to use.java.lang.IllegalArgumentException - if expression is falsepublic static void checkArgument(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
expression - a boolean expressionerrorMessageTemplate - String templateerrorMessageArgs - Arguments for the string templatejava.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 <T> T checkNotNull(T reference)
reference - an object referencejava.lang.NullPointerException - if reference is nullpublic static <T> T checkNotNull(T reference,
java.lang.Object errorMessage)
reference - an object referenceerrorMessage - the exception message to use if the check fails; will be converted to a
string using String.valueOf(Object)java.lang.NullPointerException - if reference is nullpublic static <T> T checkNotNull(T reference,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
reference - an object referenceerrorMessageTemplate - Template to be used in the message.errorMessageArgs - Arguments to be supplied to the messagejava.lang.NullPointerException - if reference is nullpublic static void checkState(boolean expression)
expression - a boolean expressionjava.lang.IllegalStateException - if expression is falsepublic static void checkState(boolean expression,
java.lang.Object errorMessage)
expression - a boolean expressionerrorMessage - the exception message to use if the check fails; will be converted to a
string using String.valueOf(Object)java.lang.IllegalStateException - if expression is falseCopyright © 2018 Amazon Web Services, Inc. All Rights Reserved.