Java Assert assertStringNotEmpty(String str, String name)

Here you can find the source of assertStringNotEmpty(String str, String name)

Description

Check if the given string is empty (trimmed).

License

Open Source License

Parameter

Parameter Description
str the given string to check
name the name to identify the string.

Exception

Parameter Description
IllegalArgumentException if the given string is not null and empty (trimmed).

Declaration

static void assertStringNotEmpty(String str, String name) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w  w  w  . jav  a 2 s  .  c om
     * Check if the given string is empty (trimmed).
     *
     * @param str  the given string to check
     * @param name the name to identify the string.
     *
     * @throws IllegalArgumentException if the given string is not null and empty (trimmed).
     */
    static void assertStringNotEmpty(String str, String name) {
        if (str != null && str.trim().length() == 0) {
            throw new IllegalArgumentException(name
                    + " should not be empty (trimmed).");
        }
    }
}

Related

  1. assertSorted(final int[] values)
  2. assertSplit(final String text, final int length)
  3. assertSquare(double[]... d)
  4. assertState(boolean expression)
  5. assertStringMatch(String first, String second)
  6. assertStringNotEmpty(String str, String name)
  7. assertStringNotEmpty(String string, String fieldName)
  8. assertTesting()
  9. assertThrows(Class exception, Runnable action)