Java Assert assertNotBlankOrThrowException(final String... strings)

Here you can find the source of assertNotBlankOrThrowException(final String... strings)

Description

assert Not Blank Or Throw Exception

License

Open Source License

Parameter

Parameter Description
strings - The list of String to check.

Exception

Parameter Description
IllegalArgumentException If at least on of the specifiedarguments 'strings' is blank or <code>null</code>.

Declaration

public static void assertNotBlankOrThrowException(final String... strings) throws IllegalArgumentException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  w  w w .  ja v  a 2  s.  c o m
     * @param strings - The list of String to check.
     * @throws IllegalArgumentException If at least one of the specified strings
     *             is blank or <tt>null</tt>.
     * @see #assertNotBlank(String...)
     * @throws IllegalArgumentException If at least on of the specified
     *             arguments 'strings' is blank or <code>null</code>.
     */
    public static void assertNotBlankOrThrowException(final String... strings) throws IllegalArgumentException {
        if (!assertNotBlank(strings))
            throw new IllegalArgumentException("Cannot be blank ! (null or empty)");
    }

    /**
     * @param strings - The list of String to check.
     * @return <code>true</code> if no <tt>String</tt> is null or blank,
     *         <code>false</code> otherwise.
     */
    public static boolean assertNotBlank(final String... strings) {
        for (String s : strings) {
            if (s == null || s.trim().isEmpty())
                return false;
        }
        return true;
    }
}

Related

  1. assertNonZero(int i, String fieldName)
  2. assertNoSlash(final String ofString)
  3. assertNotBlank(final String arg, final String message)
  4. assertNotBlank(final String value, final String exceptionMessage)
  5. assertNotBlank(final String... strings)
  6. assertNotEmpty(final String str)
  7. assertNotEmpty(String string, String exceptionMessageTitle)
  8. assertNotEmpty(String value, String message)
  9. assertNotEmptyString(final String s)