Java Utililty Methods Assert Null

List of utility methods to do Assert Null

  1. HOME
  2. Java
  3. A
  4. Assert Null

Description

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

Method

void assertAllAreNull(String messageIfNull, Object... objects)
Asserts that all of the objects are null.
for (final Object object : objects) {
 if (object != null) {
 throw new IllegalArgumentException(messageIfNull);
void assertInstance(final Object object, final Class c, final boolean allowNull)
Asserts the the given object is an instance of the given class -- optionally allowing the object to be null.
if (object == null && allowNull) {
 return;
if (object == null || c == null) {
 throw new NullPointerException();
} else if (!c.isInstance(object)) {
 throw new IllegalArgumentException();
void assertIsNull(Object obj)
Asserts that the passed entry is null
if (obj != null) {
 throw new AssertionError(
 "Passed object: " + obj.getClass().getName() + " is not null while this was expected");
T assertNonNull(final T object, final String paramName)
Throws NullPointerException with message paramName if object is null.
if (object == null) {
 throw new NullPointerException(paramName + " must not be null");
return object;
void assertNonNull(String argumentName, Object argument)
assert Non Null
if (argument == null)
 throw new IllegalArgumentException("Argument '" + argumentName + "' is null.");
void assertNoNull(Object object, String paramName)
Assert that the given object parameter is not null.
if (object == null) {
 throw new NullPointerException(paramName + " cannot be null.");
void assertNull(final Object obj, final String msg)
assert Null
if (null != obj) {
 throw new IllegalArgumentException(msg);
void assertNull(final Object value, final String name)
Asserts that the parameter's value is null.
if (value != null) {
 throw new IllegalArgumentException(PREFIX + name + " is not null.");
void assertNull(Object o)
assert Null
if (o != null) {
 throw new AssertionError("Not null.");
void assertNull(Object obj)
assert Null
if (obj != null) {
 throw new IllegalArgumentException();


AltStyle によって変換されたページ (->オリジナル) /