public final class SDKPreconditions
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
checkAllowedSize(java.util.Collection<?> collection,
int allowedSize,
java.lang.String message) |
static void |
checkArgument(boolean expression)
Ensures the truth of an expression involving one or more parameters to the calling method.
|
static <E extends java.lang.Exception> |
checkArgument(boolean expression,
E exception)
Ensures the truth of an expression involving one or more parameters to the calling method.
|
static void |
checkArgument(boolean expression,
java.lang.Object errorMessage)
Ensures the truth of an expression involving one or more parameters to the calling method.
|
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 int |
checkElementIndex(int index,
int size)
Ensures that index specifies a valid element in an array, list or string of size size.
|
static int |
checkElementIndex(int index,
int size,
java.lang.String desc)
Ensures that index specifies a valid element in an array, list or string of size size.
|
static <T,K extends java.lang.RuntimeException> |
checkNotAllNull(K exception,
T... references) |
static <T> T |
checkNotNull(T reference)
Ensures that an object reference passed as a parameter to the calling method is not null.
|
static <T> T |
checkNotNull(T reference,
java.lang.Object errorMessage)
Ensures that an object reference passed as a parameter to the calling method is not null.
|
static <T> T |
checkNotNull(T reference,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
Ensures that an object reference passed as a parameter to the calling method is not null.
|
static <T> void |
checkNotNullOrEmpty(java.util.Collection<T> collection,
java.lang.String message)
Ensures that collection is not null or empty.
|
static void |
checkNotNullOrEmpty(java.lang.String target,
java.lang.String message)
Ensures that String is not null or empty.
|
static int |
checkPositionIndex(int index,
int size)
Ensures that index specifies a valid position in an array, list or string of size size.
|
static int |
checkPositionIndex(int index,
int size,
java.lang.String desc)
Ensures that index specifies a valid position in an array, list or string of size size.
|
static void |
checkPositionIndexes(int start,
int end,
int size)
Ensures that start and end specify a valid positions in an array,
list or string of size size, and are in order.
|
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 <E extends java.lang.Exception> |
checkState(boolean expression,
E exception)
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.
|
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.
|
public static void checkArgument(boolean expression)
expression - the expressionpublic static void checkArgument(boolean expression,
java.lang.Object errorMessage)
expression - the expressionerrorMessage - the error messagepublic static <E extends java.lang.Exception> void checkArgument(boolean expression,
E exception)
throws E extends java.lang.Exception
E - the type parameterexpression - the expressionexception - the exceptionE - the eE extends java.lang.Exceptionpublic static void checkArgument(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
expression - the expressionerrorMessageTemplate - the error message templateerrorMessageArgs - the error message argspublic static void checkState(boolean expression)
expression - the expressionpublic static <E extends java.lang.Exception> void checkState(boolean expression,
E exception)
throws E extends java.lang.Exception
E - the type parameterexpression - the expressionexception - the exceptionE - the eE extends java.lang.Exceptionpublic static void checkState(boolean expression,
java.lang.Object errorMessage)
expression - the expressionerrorMessage - the error messagepublic static void checkState(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
expression - the expressionerrorMessageTemplate - the error message templateerrorMessageArgs - the error message argspublic static <T> T checkNotNull(T reference)
T - the type parameterreference - the referencepublic static <T> T checkNotNull(T reference,
java.lang.Object errorMessage)
T - the type parameterreference - the referenceerrorMessage - the error messagepublic static <T> T checkNotNull(T reference,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
T - the type parameterreference - the referenceerrorMessageTemplate - the error message templateerrorMessageArgs - the error message argspublic static <T,K extends java.lang.RuntimeException> T[] checkNotAllNull(K exception,
T... references)
public static <T> void checkNotNullOrEmpty(java.util.Collection<T> collection,
java.lang.String message)
T - the type parametercollection - the collectionmessage - the messagepublic static void checkNotNullOrEmpty(java.lang.String target,
java.lang.String message)
target - the targetmessage - the messagepublic static int checkElementIndex(int index,
int size)
index - the indexsize - the sizepublic static int checkElementIndex(int index,
int size,
java.lang.String desc)
index - the indexsize - the sizedesc - the descpublic static int checkPositionIndex(int index,
int size)
index - the indexsize - the sizepublic static int checkPositionIndex(int index,
int size,
java.lang.String desc)
index - the indexsize - the sizedesc - the descpublic static void checkPositionIndexes(int start,
int end,
int size)
start - the startend - the endsize - the sizepublic static void checkAllowedSize(java.util.Collection<?> collection,
int allowedSize,
java.lang.String message)