public class Preconditions extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
checkArgument(boolean expression)
Ensures the truth of an expression involving one or more parameters to the
calling method.
|
static void |
checkArgument(boolean expression,
Object errorMessage)
Ensures the truth of an expression involving one or more parameters to the
calling method.
|
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,
Object errorMessage)
Ensures that an object reference passed as a parameter to the calling
method is not null.
|
public static <T> T checkNotNull(T reference)
reference - an object referenceNullPointerException - if reference is nullpublic static <T> T checkNotNull(T reference,
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)NullPointerException - if reference is nullpublic static void checkArgument(boolean expression)
expression - a boolean expressionIllegalArgumentException - if expression is falsepublic static void checkArgument(boolean expression,
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)IllegalArgumentException - if expression is falseCopyright © 2018. All rights reserved.