logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1617193 - /logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/util/Strings.java
Date Mon, 11 Aug 2014 02:51:57 GMT
Author: mattsicker
Date: Mon Aug 11 02:51:56 2014
New Revision: 1617193

URL: http://svn.apache.org/r1617193
Log:
Add isBlank and isNotBlank to Strings.

Modified:
    logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/util/Strings.java

Modified: logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/util/Strings.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/util/Strings.java?rev=1617193&r1=1617192&r2=1617193&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/util/Strings.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/util/Strings.java
Mon Aug 11 02:51:56 2014
@@ -75,6 +75,27 @@ public final class Strings {
     }
 
     /**
+     * Checks if a String is blank. A blank string is one that is {@code null}, empty, or
when trimmed using
+     * {@link String#trim()} is still not empty.
+     *
+     * @param s the String to check, may be {@code null}
+     * @return {@code true} if the String is {@code null}, empty, or trims to empty.
+     */
+    public static boolean isBlank(final String s) {
+        return s == null || s.trim().isEmpty();
+    }
+
+    /**
+     * Checks if a String is not blank. The opposite of {@link #isBlank(String)}.
+     *
+     * @param s the String to check, may be {@code null}
+     * @return {@code true} if the String is non-{@code null} and has content after being
trimmed.
+     */
+    public static boolean isNotBlank(final String s) {
+        return !isBlank(s);
+    }
+
+    /**
      * <p>Removes control characters (char &lt;= 32) from both
      * ends of this String returning {@code null} if the String is
      * empty ("") after the trim or if it is {@code null}.



Mime
View raw message