List of utility methods to do Assert Not Null
void | assertObjectNotNull(String variableName, Object value) assert Object Not Null if (variableName == null) { String msg = "The value should not be null: variableName=null value=" + value; throw new IllegalArgumentException(msg); if (value == null) { String msg = "The value should not be null: variableName=" + variableName; throw new IllegalArgumentException(msg); |
void | assertObjectNotNull(String variableName, Object value) Assert that the object is not null. if (variableName == null) { String msg = "The value should not be null: variableName=null value=" + value; throw new IllegalArgumentException(msg); if (value == null) { String msg = "The value should not be null: variableName=" + variableName; throw new IllegalArgumentException(msg); |
void | assertParameterNotNull(Object parameterValue, String errorMessage) Asserts that the specified parameter value is not if (parameterValue == null) { throw new IllegalArgumentException(errorMessage); |
void | assertParamNotNull(Object check, String paramName) assert Param Not Null if (check == null) { throw new IllegalArgumentException(paramName + " is null"); |
void | assertParamNotNull(String param, String paramName) Parameter validation. if (param == null || param.isEmpty()) { throw new IllegalArgumentException("Missing Parameter '" + paramName + "' must not be null nor empty"); |
void | assertPatternNotNull(String methodName, String pattern) assert Pattern Not Null if (pattern == null) { String msg = "The argument 'pattern' should not be null: method=" + methodName; throw new IllegalArgumentException(msg); |
void | assertResourceNotNull(String resourcePath, Object resourceHandle) assert Resource Not Null if (resourceHandle == null) { throw new IllegalArgumentException("Could not find the classpath resource at: " + resourcePath + "."); |
void | assertStringNotNullAndNotTrimmedEmpty(String variableName, String value) Assert that the entity is not null and not trimmed empty. assertObjectNotNull("variableName", variableName); assertObjectNotNull("value", value); if (value.trim().length() == 0) { String msg = "The value should not be empty: variableName=" + variableName + " value=" + value; throw new IllegalArgumentException(msg); |
void | assertStringNotNullNorEmpty(String str, String name) Check if the given string is null or empty (trimmed). assertObjectNotNull(str, name); if (str.trim().length() == 0) { throw new IllegalArgumentException(name + " should not be empty (trimmed)."); |
void | assertStringNotNullOrEmpty(String str, String name) Check if the string is null or empty. assertObjectNotNull(str, name); if (str.trim().length() == 0) { throw new IllegalArgumentException(name + " must not be empty."); |