Here you can find the source of assertNotBlank(final String value, final String exceptionMessage)
Parameter | Description |
---|---|
value | the value to assert |
exceptionMessage | the exception message |
Parameter | Description |
---|---|
IllegalArgumentException | if the value is null or empty |
public static String assertNotBlank(final String value, final String exceptionMessage)
//package com.java2s; public class Main { /**//from w ww.j a va2 s. co m * Assert that the given value is not blank. If the value is blank, * an {@code IllegalArgumentException} will be thrown. * * @param value the value to assert * @param exceptionMessage the exception message * @throws IllegalArgumentException if the value is null or empty * @return the value to assert */ public static String assertNotBlank(final String value, final String exceptionMessage) { if (notBlank(value)) { return value; } throw new IllegalArgumentException(exceptionMessage); } /** * Check whether the string is not blank. * * @param string the string to check * @return true if the string is not blank */ public static boolean notBlank(final String string) { return string != null && !string.trim().isEmpty(); } }