private String joinPackageNames(String lhs, String rhs) { return StringUtils.isBlank(rhs) ? lhs : lhs + '.' + rhs; }
private String joinPackageNames(String lhs, String rhs) { return StringUtils.isBlank(rhs) ? lhs : lhs + '.' + rhs; }
/** * <p>Checks if a CharSequence is not empty (""), not null and not whitespace only.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> * StringUtils.isNotBlank(null) = false * StringUtils.isNotBlank("") = false * StringUtils.isNotBlank(" ") = false * StringUtils.isNotBlank("bob") = true * StringUtils.isNotBlank(" bob ") = true * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if the CharSequence is not empty and not null and not whitespace only * @since 2.0 * @since 3.0 Changed signature from isNotBlank(String) to isNotBlank(CharSequence) */ public static boolean isNotBlank(final CharSequence cs) { return !isBlank(cs); }
/** * <p>Checks if a CharSequence is not empty (""), not null and not whitespace only.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> * StringUtils.isNotBlank(null) = false * StringUtils.isNotBlank("") = false * StringUtils.isNotBlank(" ") = false * StringUtils.isNotBlank("bob") = true * StringUtils.isNotBlank(" bob ") = true * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if the CharSequence is not empty and not null and not whitespace only * @since 2.0 * @since 3.0 Changed signature from isNotBlank(String) to isNotBlank(CharSequence) */ public static boolean isNotBlank(final CharSequence cs) { return !isBlank(cs); }
private void isNotBlank(String value, String fieldName) { if (isBlank(value)) { if (sb.length() > 0) { sb.append(", "); } sb.append(fieldName).append(" should not be null or blank"); } } };
private void isNotBlank(String value, String fieldName) { if (isBlank(value)) { if (sb.length() > 0) { sb.append(", "); } sb.append(fieldName).append(" should not be null or blank"); } } };
/** * <p>Validate that the specified char sequence is neither * {@code null}, a length of zero (no characters), empty nor * whitespace; otherwise throwing an exception with the specified * message. * * <pre>Validate.paramNotBlank(myCharSequence, "myCharSequence");</pre> * * @param <T> the char sequence type * @param chars the character sequence to check * @param paramName The name of the param or field being checked. * @return the validated char sequence (never {@code null} for method chaining) * @throws NullPointerException if the char sequence is {@code null} */ public static <T extends CharSequence> T paramNotBlank(final T chars, final String paramName) { if (chars == null) { throw new NullPointerException(String.format("%s must not be null.", paramName)); } if (StringUtils.isBlank(chars)) { throw new IllegalArgumentException(String.format("%s must not be blank or empty.", paramName)); } return chars; }
/** * <p>Validate that the specified char sequence is neither * {@code null}, a length of zero (no characters), empty nor * whitespace; otherwise throwing an exception with the specified * message. * * <pre>Validate.paramNotBlank(myCharSequence, "myCharSequence");</pre> * * @param <T> the char sequence type * @param chars the character sequence to check * @param paramName The name of the param or field being checked. * @return the validated char sequence (never {@code null} for method chaining) * @throws NullPointerException if the char sequence is {@code null} */ public static <T extends CharSequence> T paramNotBlank(final T chars, final String paramName) { if (chars == null) { throw new NullPointerException(String.format("%s must not be null.", paramName)); } if (StringUtils.isBlank(chars)) { throw new IllegalArgumentException(String.format("%s must not be blank or empty.", paramName)); } return chars; }
/** * <p>Validate that the specified argument character sequence is * neither {@code null}, a length of zero (no characters), empty * nor whitespace; otherwise throwing an exception with the specified * message. * * <pre>Validate.notBlank(myString, "The string must not be blank");</pre> * * @param <T> the character sequence type * @param chars the character sequence to check, validated not null by this method * @param message the {@link String#format(String, Object...)} exception message if invalid, not null * @param values the optional values for the formatted exception message, null array not recommended * @return the validated character sequence (never {@code null} method for chaining) * @throws NullPointerException if the character sequence is {@code null} * @throws IllegalArgumentException if the character sequence is blank */ public static <T extends CharSequence> T notBlank(final T chars, final String message, final Object... values) { if (chars == null) { throw new NullPointerException(String.format(message, values)); } if (StringUtils.isBlank(chars)) { throw new IllegalArgumentException(String.format(message, values)); } return chars; }
/** * <p>Validate that the specified argument character sequence is * neither {@code null}, a length of zero (no characters), empty * nor whitespace; otherwise throwing an exception with the specified * message. * * <pre>Validate.notBlank(myString, "The string must not be blank");</pre> * * @param <T> the character sequence type * @param chars the character sequence to check, validated not null by this method * @param message the {@link String#format(String, Object...)} exception message if invalid, not null * @param values the optional values for the formatted exception message, null array not recommended * @return the validated character sequence (never {@code null} method for chaining) * @throws NullPointerException if the character sequence is {@code null} * @throws IllegalArgumentException if the character sequence is blank */ public static <T extends CharSequence> T notBlank(final T chars, final String message, final Object... values) { if (chars == null) { throw new NullPointerException(String.format(message, values)); } if (StringUtils.isBlank(chars)) { throw new IllegalArgumentException(String.format(message, values)); } return chars; }