public final class Assertions
extends java.lang.Object
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
checkArgument(boolean expression)
Throws
IllegalArgumentException if expression evaluates to false. |
static void |
checkArgument(boolean expression,
java.lang.Object errorMessage)
Throws
IllegalArgumentException if expression evaluates to false. |
static <T> T |
checkNotNull(T reference)
Throws
NullPointerException if reference is null. |
static void |
checkState(boolean expression)
Throws
IllegalStateException if expression evaluates to false. |
static void |
checkState(boolean expression,
java.lang.Object errorMessage)
Throws
IllegalStateException if expression evaluates to false. |
static <T> T |
checkStateNotNull(T reference,
java.lang.Object errorMessage)
Throws
IllegalStateException if reference is null. |
public static void checkArgument(boolean expression)
IllegalArgumentException if expression evaluates to false.expression - The expression to evaluate.java.lang.IllegalArgumentException - If expression is false.public static void checkArgument(boolean expression,
java.lang.Object errorMessage)
IllegalArgumentException if expression evaluates to false.expression - The expression to evaluate.errorMessage - The exception message if an exception is thrown. The message is converted
to a String using String.valueOf(Object).java.lang.IllegalArgumentException - If expression is false.public static void checkState(boolean expression)
IllegalStateException if expression evaluates to false.expression - The expression to evaluate.java.lang.IllegalStateException - If expression is false.public static void checkState(boolean expression,
java.lang.Object errorMessage)
IllegalStateException if expression evaluates to false.expression - The expression to evaluate.errorMessage - The exception message if an exception is thrown. The message is converted
to a String using String.valueOf(Object).java.lang.IllegalStateException - If expression is false.public static <T> T checkStateNotNull(T reference,
java.lang.Object errorMessage)
IllegalStateException if reference is null.T - The type of the reference.reference - The reference.errorMessage - The exception message to use if the check fails. The message is converted
to a string using String.valueOf(Object).java.lang.IllegalStateException - If reference is null.public static <T> T checkNotNull(T reference)
NullPointerException if reference is null.T - The type of the reference.reference - The reference.java.lang.NullPointerException - If reference is null.