Here you can find the source of assertStringNotNullNorEmpty(String str, String name)
Parameter | Description |
---|---|
str | the given string to check |
name | the name to identify the string. |
Parameter | Description |
---|---|
IllegalArgumentException | if the given string is null or empty (trimmed). |
static void assertStringNotNullNorEmpty(String str, String name)
//package com.java2s; public class Main { /**/* w w w. j a va 2s . co m*/ * Check if the given string is null or empty (trimmed). * * @param str the given string to check * @param name the name to identify the string. * @throws IllegalArgumentException if the given string is null or empty (trimmed). */ static void assertStringNotNullNorEmpty(String str, String name) { assertObjectNotNull(str, name); if (str.trim().length() == 0) { throw new IllegalArgumentException(name + " should not be empty (trimmed)."); } } /** * Check if the given object is null. * * @param obj the given object to check * @param name the name to identify the object. * @throws IllegalArgumentException if the given object is null */ static void assertObjectNotNull(Object obj, String name) { if (obj == null) { throw new IllegalArgumentException(name + " should not be null."); } } }