Here you can find the source of assertStringNotNullOrEmpty(String str, String name)
Check if the string is null or empty.
Parameter | Description |
---|---|
str | the string to check. |
name | the string's name. |
Parameter | Description |
---|---|
IllegalArgumentException | if the string is null or empty. |
public static void assertStringNotNullOrEmpty(String str, String name)
//package com.java2s; public class Main { /**/* ww w. j a v a2 s. c om*/ * <p> * Check if the string is null or empty. * </p> * @param str * the string to check. * @param name * the string's name. * @throws IllegalArgumentException * if the string is null or empty. */ public static void assertStringNotNullOrEmpty(String str, String name) { assertObjectNotNull(str, name); if (str.trim().length() == 0) { throw new IllegalArgumentException(name + " must not be empty."); } } /** * <p> * Check if the given object is null. * </p> * @param obj * the object to check. * @param name * the object's name * @throws IllegalArgumentException * if the object is null. */ public static void assertObjectNotNull(Object obj, String name) { if (obj == null) { throw new IllegalArgumentException(name + " must not be null."); } } }