From 3ce7f9eecfacbf3de716a8338ad4929371a66ca2 Mon Sep 17 00:00:00 2001 From: pascalschumacher Date: Sun, 12 Mar 2017 17:21:27 +0100 Subject: [PATCH] revert "LANG-1270: Add StringUtils#isAnyNotEmpty and #isAnyNotBlank" and add "LANG-1293: Add StringUtils#isAllEmpty and #isAllBlank methods" instead --- src/changes/changes.xml | 2 +- .../org/apache/commons/lang3/StringUtils.java | 83 ++++--------------- .../lang3/StringUtilsEmptyBlankTest.java | 26 ------ 3 files changed, 19 insertions(+), 92 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 5b2cb6450..595fcc821 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -66,7 +66,7 @@ The type attribute can be add,update,fix,remove. Implementation of a Memomizer Add ArrayUtils#toStringArray method StringUtils#abbreviate should support 'custom ellipses' parameter - Add StringUtils#isAnyNotEmpty and #isAnyNotBlank + Add StringUtils#isAllEmpty and #isAllBlank methods Provide annotations to document thread safety Increase test coverage of org.apache.commons.lang3.ArrayUtils StrSubstitutor should state its thread safety diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index d91ad5513..56a1c4782 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -258,36 +258,6 @@ public class StringUtils { return false; } - /** - *

Checks if any of the CharSequences are not empty ("") and not null.

- * - *
-     * StringUtils.isAnyNotEmpty(null)             = false
-     * StringUtils.isAnyNotEmpty(new String[] {})  = false
-     * StringUtils.isAnyNotEmpty(null, "foo")      = true
-     * StringUtils.isAnyNotEmpty("", "bar")        = true
-     * StringUtils.isAnyNotEmpty("bob", "")        = true
-     * StringUtils.isAnyNotEmpty("  bob  ", null)  = true
-     * StringUtils.isAnyNotEmpty(" ", "bar")       = true
-     * StringUtils.isAnyNotEmpty("foo", "bar")     = true
-     * 
- * - * @param css the CharSequences to check, may be null or empty - * @return {@code true} if any of the CharSequences are not empty and not null - * @since 3.6 - */ - public static boolean isAnyNotEmpty(final CharSequence... css) { - if (ArrayUtils.isEmpty(css)) { - return false; - } - for (final CharSequence cs : css) { - if (isNotEmpty(cs)) { - return true; - } - } - return false; - } - /** *

Checks if none of the CharSequences are empty ("") or null.

* @@ -330,7 +300,15 @@ public class StringUtils { * @since 3.6 */ public static boolean isAllEmpty(final CharSequence... css) { - return !isAnyNotEmpty(css); + if (ArrayUtils.isEmpty(css)) { + return true; + } + for (final CharSequence cs : css) { + if (isNotEmpty(cs)) { + return false; + } + } + return true; } /** @@ -420,39 +398,6 @@ public class StringUtils { return false; } - /** - *

Checks if any of the CharSequences are not empty (""), not null and not whitespace only.

- * - *

Whitespace is defined by {@link Character#isWhitespace(char)}.

- * - *
-     * StringUtils.isAnyNotBlank(null)             = false
-     * StringUtils.isAnyNotBlank(null, "foo")      = true
-     * StringUtils.isAnyNotBlank(null, null)       = false
-     * StringUtils.isAnyNotBlank("", "bar")        = true
-     * StringUtils.isAnyNotBlank("bob", "")        = true
-     * StringUtils.isAnyNotBlank("  bob  ", null)  = true
-     * StringUtils.isAnyNotBlank(" ", "bar")       = true
-     * StringUtils.isAnyNotBlank("foo", "bar")     = true
-     * StringUtils.isAnyNotBlank(new String[] {})  = false
-     * 
- * - * @param css the CharSequences to check, may be null or empty - * @return {@code true} if any of the CharSequences are not empty and not null and not whitespace only - * @since 3.6 - */ - public static boolean isAnyNotBlank(final CharSequence... css) { - if (ArrayUtils.isEmpty(css)) { - return false; - } - for (final CharSequence cs : css) { - if (isNotBlank(cs)) { - return true; - } - } - return false; - } - /** *

Checks if none of the CharSequences are empty (""), null or whitespace only.

* @@ -500,7 +445,15 @@ public class StringUtils { * @since 3.6 */ public static boolean isAllBlank(final CharSequence... css) { - return !isAnyNotBlank(css); + if (ArrayUtils.isEmpty(css)) { + return true; + } + for (final CharSequence cs : css) { + if (isNotBlank(cs)) { + return false; + } + } + return true; } // Trim diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java index b04d0daef..8e88f6ea3 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java @@ -56,19 +56,6 @@ public class StringUtilsEmptyBlankTest { assertFalse(StringUtils.isAnyEmpty("foo", "bar")); } - @Test - public void testIsAnyNotEmpty() { - assertFalse(StringUtils.isAnyNotEmpty((String) null)); - assertFalse(StringUtils.isAnyNotEmpty((String[]) null)); - assertTrue(StringUtils.isAnyNotEmpty(null, "foo")); - assertTrue(StringUtils.isAnyNotEmpty("", "bar")); - assertTrue(StringUtils.isAnyNotEmpty("bob", "")); - assertTrue(StringUtils.isAnyNotEmpty(" bob ", null)); - assertTrue(StringUtils.isAnyNotEmpty(" ", "bar")); - assertTrue(StringUtils.isAnyNotEmpty("foo", "bar")); - assertFalse(StringUtils.isAnyNotEmpty("", null)); - } - @Test public void testIsNoneEmpty() { assertFalse(StringUtils.isNoneEmpty((String) null)); @@ -127,19 +114,6 @@ public class StringUtilsEmptyBlankTest { assertFalse(StringUtils.isAnyBlank("foo", "bar")); } - @Test - public void testIsAnyNotBlank() { - assertFalse(StringUtils.isAnyNotBlank((String) null)); - assertFalse(StringUtils.isAnyNotBlank((String[]) null)); - assertTrue(StringUtils.isAnyNotBlank(null, "foo")); - assertFalse(StringUtils.isAnyNotBlank(null, null)); - assertTrue(StringUtils.isAnyNotBlank("", "bar")); - assertTrue(StringUtils.isAnyNotBlank("bob", "")); - assertTrue(StringUtils.isAnyNotBlank(" bob ", null)); - assertTrue(StringUtils.isAnyNotBlank(" ", "bar")); - assertTrue(StringUtils.isAnyNotBlank("foo", "bar")); - } - @Test public void testIsNoneBlank() { assertFalse(StringUtils.isNoneBlank((String) null));