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)
Deprecated.
|
static <T> T |
notNull(T x,
String message)
|
static <T,U extends Collection<T>> |
notNullAll(U x)
Deprecated.
|
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 NullCheckException iff
x == null . |
@Deprecated @NonNull public static <T> T notNull(@Nullable T x)
notNull(Object, String)
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
@Deprecated @NonNull public static <T,U extends Collection<T>> U notNullAll(@Nullable U x)
notNullAll(Collection, String)
x
is not null, and that all elements of
x
are not null, raising NullCheckException
iff
x == null
.T
- The type of valuesU
- The type of collections of T
x
- 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 NullCheckException
iff
x == null
.T
- The type of valuesU
- The type of collections of T
x
- An arbitrary valuemessage
- A descriptive message describing the valuex
Copyright © 2017 <code@io7m.com> http://io7m.com