Java Utililty Methods Assert Not Null

List of utility methods to do Assert Not Null

Description

The list of methods to do Assert Not Null are organized into topic(s).

Method

voidassertNotNull(final Object object, final String message)
Check that an object is null and throw NullPointerException in the case.
if (object == null) {
    throw new NullPointerException(message == null ? "Object is null" : message);
voidassertNotNull(final Object object, final String message)
Check whether the object is null or not.
if (object == null) {
    throw new IllegalArgumentException(message);
voidassertNotNull(final Object param, final String name)
assert Not Null
if (param == null)
    throw new IllegalArgumentException(String.format("NULL %s", (name != null) ? name : "parameter"));
voidassertNotNull(final Object value, final String name)
Asserts that the parameter's value is not null.
if (value == null) {
    throw new NullPointerException(PREFIX + name + " is null.");
booleanassertNotNull(final Object... objects)
assert Not Null
for (Object obj : objects) {
    if (obj == null) {
        return false;
return true;
voidassertNotNull(final String message, final Object obj)
assert Not Null
if (obj == null) {
    throw new NullPointerException(message);
voidassertNotNull(final String message, final Object object)
assert Not Null
assertTrue(message, object != null);
TassertNotNull(final String name, final T object)
assert Not Null
if (object == null)
    throw new IllegalArgumentException(String.format("%s == null", name));
return object;
voidassertNotNull(final String param, final Object value)
Asserts that a value is not null.
if (value == null) {
    throw new IllegalArgumentException(param);
TassertNotNull(final T object, final String message)
Checks if the given object is null.
If it is, a new NullPointerException is thrown with the given message.
if (object == null) {
    throw new NullPointerException(message);
return object;