Java Utililty Methods Assert Null

List of utility methods to do Assert Null

Description

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

Method

voidassertNull(Object obj)
assert Null
assertNull(obj, "[Assertion failed] - This object argument must be null.");
voidassertNull(Object object)
Check that object is null.
if (object != null) {
    throw new IllegalArgumentException("[Assertion failed] - the object argument must be null");
voidassertNull(Object object, String errMsg)
assert Null
if (object != null) {
    throw new RuntimeException(errMsg);
voidassertNull(Object object, String message)
Solleva una @link(IllegalArgumentException) con message message in caso di object non null
if (object != null) {
    throw new IllegalArgumentException(message);
voidassertNull(String message, Object object)
assert Null
assertTrue(message, object == null);
voidassertNull(String message, Object object)
Asserts that an object is null.
assertTrue(message, object == null);
voidassertNull(String message, Object val)
assert Null
if (message != null)
    assert val == null : message;
else
    assert val == null;
voidassertNull(String string, Object obj)
assert Null
assertTrue(string, obj == null);
voidassertObjectNullOrIsInstance(Object obj, Class expectedType, String name)
Check if the given object is an instance of the expected class.
if (obj != null && !expectedType.isInstance(obj)) {
    throw new IllegalArgumentException(name + " of type [" + obj.getClass().getName()
            + "] should be an instance of " + expectedType.getName());