List of utility methods to do Assert
void | assertNotBlank(final String arg, final String message) Throws an IllegalArgumentException with the given message if null or blank. if (arg == null) { throw new IllegalArgumentException("Null argument not allowed: " + message); if (arg.trim().equals("")) { throw new IllegalArgumentException("Blank argument not allowed: " + message); |
String | assertNotBlank(final String value, final String exceptionMessage) Assert that the given value is not blank. if (notBlank(value)) { return value; throw new IllegalArgumentException(exceptionMessage); |
boolean | assertNotBlank(final String... strings) assert Not Blank for (String s : strings) { if (s == null || s.trim().isEmpty()) return false; return true; |
void | assertNotBlankOrThrowException(final String... strings) assert Not Blank Or Throw Exception if (!assertNotBlank(strings)) throw new IllegalArgumentException("Cannot be blank ! (null or empty)"); |
boolean | assertNotEmpty(final String str) assert Not Empty return null != str && !str.isEmpty();
|
void | assertNotEmpty(String string, String exceptionMessageTitle) assert Not Empty if (isNullOrEmpty(string)) { throw new IllegalArgumentException(exceptionMessageTitle + " cannot be null or empty string"); |
void | assertNotEmpty(String value, String message) assert Not Empty if (value == null || "".equals(value)) { throw new IllegalArgumentException(message); |
void | assertNotEmptyString(final String s) assert Not Empty String if ("".equals(s)) { throw new IllegalArgumentException("Method parameter cannot be empty string"); |
void | assertNotEquals(final Object actual, final Object expected, final String name) Asserts that two parameters don't have the same value. if (actual == null) { if (expected == null) { throw new IllegalArgumentException(PREFIX + name + " is equals the expected one."); } else { if (actual.equals(expected)) { throw new IllegalArgumentException(PREFIX + name + " is equals the expected one."); |
void | assertNotMatches(String name, String regExp, String actual) assert Not Matches if (matches(regExp, actual)) { throw new AssertionError(name + ": " + actual + " is matching " + regExp + " when it shouldn't!"); |