public final class NullCheck extends Object
Functions for enforcing non-nullable references at run time.
The functions are intended for use in the manner of assertions. That is,
the program should behave identically if all of the checks are removed. The
functions raise NullCheckException to indicate that a null
reference has been explicitly forbidden (rather than the accidental
deference implied by NullPointerException). Exceptions of this type
are not intended to be caught and handled; they indicate program
bugs.
NullCheckException| Modifier and Type | Method and Description |
|---|---|
static <T> T |
notNull(T x)
|
static <T> T |
notNull(T x,
String message)
|
static <T,U extends Collection<T>> |
notNullAll(U x)
Check that
x is not null, and that all elements of
x are not null, raising NullPointerException iff
x == null. |
static <T,U extends Collection<T>> |
notNullAll(U x,
String message)
Check that
x is not null, and that all elements of
x are not null, raising NullPointerException iff
x == null. |
@NonNull public static <T> T notNull(@Nullable T x)
T - The type of valuesx - An arbitrary valuex@NonNull public static <T> T notNull(@Nullable T x, @NonNull String message)
T - The type of valuesx - An arbitrary valuemessage - A descriptive message describing the valuex@NonNull public static <T,U extends Collection<T>> U notNullAll(@Nullable U x)
x is not null, and that all elements of
x are not null, raising NullPointerException iff
x == null.T - The type of valuesU - The type of collections of Tx - An arbitrary valuex@NonNull public static <T,U extends Collection<T>> U notNullAll(@Nullable U x, @NonNull String message)
x is not null, and that all elements of
x are not null, raising NullPointerException iff
x == null.T - The type of valuesU - The type of collections of Tx - An arbitrary valuemessage - A descriptive message describing the valuexCopyright © 2014 <code@io7m.com> http://io7m.com