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 T value, final String param)
This method verifies if the input argument is null or not.
if (null == value) {
    throw new IllegalArgumentException(
            ILLEGAL_ARGUMENT_EXCEPTION_MSG + ((null != param) ? param : "unknown"));
voidassertNotNull(Object argumentThatMustNotBeNull, String argumentName)
assert Not Null
if (argumentThatMustNotBeNull == null) {
    throw new IllegalArgumentException(argumentName + " must not be null.");
voidassertNotNull(Object expression)
assert Not Null
assert expression != null : TRANSFORM_WITHOUT_CHECK;
voidassertNotNull(Object o)
assert Not Null
if (o == null) {
    throw new AssertionError("Null.");
voidassertNotNull(Object obj)
Method assertNotNull.
if (obj == null) {
    throw new RuntimeException("assertion: must not be null");
voidassertNotNull(Object obj)
assert Not Null
assertNotNull(obj, "[Assertion failed] - This object argument object must not be null.");
voidassertNotNull(Object obj, RuntimeException ex)
assert Not Null
if (obj == null) {
    throw ex;
voidassertNotNull(Object obj, String msgTemplate, Object... params)
assert Not Null
if (obj == null) {
    throw new NullPointerException(getMsg("Assert fail: should not be null", msgTemplate, params));
voidassertNotNull(Object obj, String name)

Checks whether the given Object is not null.

if (obj == null) {
    throw new IllegalArgumentException("[ " + name + " ] should not be null.");
voidassertNotNull(Object obj, String name)
assert Not Null
if (obj == null) {
    throw new IllegalArgumentException("Null " + name + " arguments are not accepted!");