public final class Preconditions
extends java.lang.Object
checkNotNullWithMessage, an object reference which is expected to be non-null). When false (or null) is passed instead, the Preconditions method throws an unchecked
exception, which helps the calling method communicate to its caller that that
caller has made a mistake.| 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 <T> T |
checkNotNull(T reference,
java.lang.String name)
Ensures that an object reference passed as a parameter to the calling method is not null.
|
static <T> T |
checkNotNullWithMessage(T reference,
java.lang.String message)
Ensures that an object reference passed as a parameter to the calling method is not null.
|
static <T> T |
checkNotNullWithMessage(T reference,
java.lang.String messageFormat,
java.lang.Object... args)
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 referencejava.lang.NullPointerException - if reference is nullpublic static <T> T checkNotNull(T reference,
java.lang.String name)
reference - an object referencename - an object reference namejava.lang.NullPointerException - if reference is nullpublic static <T> T checkNotNullWithMessage(T reference,
java.lang.String message)
reference - an object referencemessage - exception message should the check failjava.lang.NullPointerException - if reference is nullpublic static <T> T checkNotNullWithMessage(T reference,
java.lang.String messageFormat,
java.lang.Object... args)
reference - an object referencemessageFormat - exception message as described in
format stringargs - arguments referenced by the messageFormat specifiersjava.lang.NullPointerException - if reference is null