/** * Checks if {@code value} is blank providing an additional message. * * @param name the name of the argument of error reporting. Not used if no * exception is thrown. May be <code>null</code>, although not * recommended. * @param value the value of the argument to check to be not blank. * @param message the message to pass to the exception as additional * information to the standard message being generated. * @throws BlankArgumentException if {@code value} is blank. */ public static void checkNotBlank(final String name, final String value, final String message) throws BlankArgumentException { if (StringUtils.isBlank(value)) { throw new BlankArgumentException(name, message); } }
/** * Checks if {@code value} is blank except <code>null</code> providing an * additional message. * * @param name the name of the argument of error reporting. Not used if no * exception is thrown. May be <code>null</code>, although not * recommended. * @param value the value of the argument to check to be not blank but may be * <code>null</code>. * @param message the message to pass to the exception as additional * information to the standard message being generated. * @throws BlankExceptNullArgumentException if {@code value} is blank and not * <code>null</code>. */ public static void checkNotBlankExceptNull(final String name, final String value, final String message) throws BlankExceptNullArgumentException { if (value != null && StringUtils.isBlank(value)) { throw new BlankArgumentException(name, message); } }
/** * Creates the report item. * * @return the report item. */ public PropertyReportSet build() { if (StringUtils.isBlank(type)) { throw new BlankArgumentException("type", "Building property set failed."); } return new PropertyReportSet(this); }
/** * Checks if {@code value} is blank except <code>null</code> providing an * additional message. * * @param name the name of the argument of error reporting. Not used if no * exception is thrown. May be <code>null</code>, although not * recommended. * @param value the value of the argument to check to be not blank but may be * <code>null</code>. * @param message the message to pass to the exception as additional * information to the standard message being generated. * @return the passed in {@code value}. * @throws BlankExceptNullArgumentException if {@code value} is blank and not * <code>null</code>. * @param <T> a character sequence like a {@link String}. */ public static <T extends CharSequence> T checkNotBlankExceptNull( final String name, final T value, final String message) throws BlankExceptNullArgumentException { if (value != null && isBlank(value)) { throw new BlankArgumentException(name, message); } return value; }
/** * Checks if {@code value} is blank providing an additional message. * * @param name the name of the argument of error reporting. Not used if no * exception is thrown. May be <code>null</code>, although not * recommended. * @param value the value of the argument to check to be not blank. * @param message the message to pass to the exception as additional * information to the standard message being generated. * @return the passed in {@code value}. * @throws NullArgumentException if {@code value} is <code>null</code>. * @throws BlankArgumentException if {@code value} is blank. * @param <T> a character sequence like a {@link String}. */ public static <T extends CharSequence> T checkNotBlank(final String name, final T value, final String message) throws NullArgumentException, BlankArgumentException { if (value == null) { throw new NullArgumentException(name, message); } if (isBlank(value)) { throw new BlankArgumentException(name, message); } return value; }