List of utility methods to do Assert Not Null
void | assertArgNotNull(final String argName, final Object argValue) assert Arg Not Null if (argValue == null) { throw new IllegalArgumentException("Argument '" + argName + "' cannot be null"); |
void | assertArgNotNull(T obj, String name) assert Arg Not Null if (obj == null) { throw new IllegalArgumentException("argument " + name == null ? "" : name + " is null"); |
T | assertArgumentNotNull(T argument, String argumentName) Throws an IllegalArgumentException if the provided argument is null. if (argument == null) throw new IllegalArgumentException("Argument cannot be null - '" + argumentName + "'"); return argument; |
void | assertElementNotNull(Object element, Class> elementClass) assert Element Not Null if (element == null) { throw new IllegalArgumentException(elementClass.getName() + " must be set"); |
void | assertFieldNotNull(Object fieldValue, String fieldName) Throws an IllegalArgumentException if the specified field is if (fieldValue == null) throw new IllegalArgumentException("Field '" + fieldName + "' cannot be null."); |
Object | assertFormatResultNotNull(Object r) assert Format Result Not Null if (r != null) { return r; throw new NullPointerException("TemplateValueFormatter result can't be null"); |
void | assertInstanceOfNotNull(Object obj, Class> expClass) Checks if the passed object is of the class specified, null values throw an exception if (obj == null) { throw new AssertionError( "Checking instanceof but object is null, expecting class: " + expClass.getName()); if (!(expClass.isAssignableFrom(obj.getClass()))) { throw new AssertionError( "Expected class: " + expClass.getName() + " but object has class: " + obj.getClass().getName()); |
void | assertNotNull(final Object o, final String message) assert Not Null if (o == null) throw new NullPointerException(message); |
void | assertNotNull(final Object obj, final String msg) assert Not Null if (null == obj) { throw new IllegalArgumentException(msg); |
void | assertNotNull(final Object obj, final String reference) assert Not Null if (obj == null) { throw new IllegalArgumentException(String .format("[Assertion failed error. Expected not null reference %s, but got <NULL>]", reference)); |