List of utility methods to do Assert Not Null
T | assertNotNull(T obj) assert Not Null if (obj == null) { throw new NullPointerException(); return obj; |
T | assertNotNull(T object, String fieldName) Asserts that the given object is non-null and returns it. if (object == null) { throw new IllegalArgumentException(String.format("%s cannot be null", fieldName)); return object; |
T | assertNotNull(T value, String message) assert Not Null if (value == null) { throw new IllegalArgumentException(message); return value; |
void | assertNotNullArg(Object value, String argName) assert Not Null Arg if (value == null) throw new IllegalArgumentException(argName + " cannot be null"); |
void | assertNotNullArgument(Object obj, String argName) assert Not Null Argument if (obj == null) { throw new IllegalArgumentException("Null Object specified as argument. argumentName[" + argName + "]"); if (obj instanceof String) { assertQualifiedString((String) obj, argName); |
void | assertNotNullEightBytes(byte[] bytes) assert Not Null Eight Bytes if (bytes == null) { throw new IllegalArgumentException("Expected 8 bytes, but got null."); if (bytes.length != 8) { throw new IllegalArgumentException(String.format("Expected 8 bytes, but got: %d bytes.", bytes.length)); |
void | assertNotNullNotEmpty(String obj, String paramName) assert Not Null Not Empty assertNotNull(obj, paramName); if (obj.isEmpty()) { throw new IllegalArgumentException(paramName + " cannot be empty"); |
void | assertNotNullOrThrowException(final Object... objects) assert Not Null Or Throw Exception if (!assertNotNull(objects)) throw new IllegalArgumentException("Cannot be null !"); |
void | assertObjectNotNull(final Object object) assert Object Not Null assert object != null;
|
void | assertObjectNotNull(Object o, String name) assert Object Not Null if (o == null) { throw new NullPointerException(name); |