/** * Assert that the given text does not contain the given substring. * * <pre class="code"> * Assert.doesNotContain(name, "rod", "Name must not contain 'rod'"); * </pre> * * @param textToSearch the text to search * @param substring the substring to find within the text * @param message the exception message to use if the assertion fails */ public static void doesNotContain(String textToSearch, String substring, String message) { if (DataUtil.isNotNullOrEmpty(textToSearch) && DataUtil.isNotNullOrEmpty(substring) && textToSearch.indexOf(substring) != -1) { throw new IllegalArgumentException(message); } }
/** * Assert that the given String has valid text content; that is, it must not be <code>null</code> * and must contain at least one non-whitespace character. * * <pre class="code"> * Assert.hasText(name, "'name' must not be empty"); * </pre> * * @param text the String to check * @param message the exception message to use if the assertion fails */ public static void hasText(String text, String message) { if (!DataUtil.isNotNullOrEmpty(text)) { throw new IllegalArgumentException(message); } }