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(Object... params)
Check that object is not null.
if (params != null) {
    for (int idx = 0; idx < params.length; idx++) {
        Object currentparam = params[idx];
        if (null == currentparam) {
            throw new IllegalArgumentException(
                    "[Assertion failed] - Parameter #" + idx + "(object)  must not be null");
voidassertNotNull(Object... params)
Check that object is not null.
assertNotNull("parameter", params);
voidassertNotNull(String errorMessage, Object... args)
assert Not Null
if (args == null || args.length == 0) {
    throw new IllegalArgumentException("Nie podano argumentow do ewaluacji");
for (Object s : args) {
    if (s == null) {
        throw new IllegalArgumentException("Argument nie moze byc nullem");
voidassertNotNull(String fieldName, Object object)
assert Not Null
return;
voidassertNotNull(String message, Object object)
Asserts that an object isn't null.
assertTrue(message, object != null);
voidassertNotNull(String message, Object val)
assert Not Null
if (message != null)
    assert val != null : message;
else
    assert val != null;
ObjectassertNotNull(String variableName, Object value)
Method throws NullPointerException when the variable named variableName has a null value.
if (value == null)
    throw new NullPointerException("The variable named " + variableName + " is null.");
return value;
voidassertNotNull(StringBuilder buffer)
assert Not Null
if (buffer == null) {
    throw new NullPointerException("The buffer cannot be null");
voidassertNotNull(T exception, Object... objects)
assert Not Null
for (Object object : objects) {
    if (object == null) {
        throw exception;
TassertNotNull(T o)
assert Not Null
if (o == null) {
    throw new AssertionError("A reference was unexpectedly null.");
return o;