File tree Expand file tree Collapse file tree 2 files changed +17
-12
lines changed
main/java/org/codehaus/plexus/util
test/java/org/codehaus/plexus/util Expand file tree Collapse file tree 2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -156,9 +156,7 @@ public static String deleteWhitespace( String str )
156156 }
157157
158158 /**
159- * <p>
160159 * Checks if a String is non <code>null</code> and is not empty (<code>length > 0</code>).
161- * </p>
162160 *
163161 * @param str the String to check
164162 * @return true if the String is non-null, and not length zero
@@ -169,21 +167,18 @@ public static boolean isNotEmpty( String str )
169167 }
170168
171169 /**
170+ * Checks if a String is <code>null</code> or empty.
172171 * <p>
173- * Checks if a (trimmed) String is <code>null</code> or empty.
174- * </p>
175- * <p>
176- * <strong>Note:</strong> In future releases, this method will no longer trim the input string such that it works
177- * complementary to {@link #isNotEmpty(String)}. Code that wants to test for whitespace-only strings should be
178- * migrated to use {@link #isBlank(String)} instead.
179- * </p>
172+ * <strong>Note:</strong> In releases prior 3.5.0, this method trimmed the input string such that it worked
173+ * the same as {@link #isBlank(String)}. Since release 3.5.0 it no longer returns {@code true} for strings
174+ * containing whitespace.
180175 *
181176 * @param str the String to check
182- * @return <code>true</code> if the String is <code>null</code>, or length zero once trimmed
177+ * @return <code>true</code> if the String is <code>null</code>, or length zero
183178 */
184179 public static boolean isEmpty ( String str )
185180 {
186- return ( ( str == null ) || ( str .trim (). isEmpty () ) );
181+ return ( ( str == null ) || ( str .isEmpty () ) );
187182 }
188183
189184 /**
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ public void testIsEmpty()
4343 {
4444 assertEquals ( true , StringUtils .isEmpty ( null ) );
4545 assertEquals ( true , StringUtils .isEmpty ( "" ) );
46- assertEquals ( true , StringUtils .isEmpty ( " " ) );
46+ assertEquals ( false , StringUtils .isEmpty ( " " ) );
4747 assertEquals ( false , StringUtils .isEmpty ( "foo" ) );
4848 assertEquals ( false , StringUtils .isEmpty ( " foo " ) );
4949 }
@@ -61,6 +61,16 @@ public void testIsNotEmpty()
6161 assertEquals ( true , StringUtils .isNotEmpty ( " foo " ) );
6262 }
6363
64+ @ Test
65+ public void testIsNotEmptyNegatesIsEmpty ()
66+ {
67+ assertEquals ( !StringUtils .isEmpty ( null ), StringUtils .isNotEmpty ( null ) );
68+ assertEquals ( !StringUtils .isEmpty ( "" ), StringUtils .isNotEmpty ( "" ) );
69+ assertEquals ( !StringUtils .isEmpty ( " " ), StringUtils .isNotEmpty ( " " ) );
70+ assertEquals ( !StringUtils .isEmpty ( "foo" ), StringUtils .isNotEmpty ( "foo" ) );
71+ assertEquals ( !StringUtils .isEmpty ( " foo " ), StringUtils .isNotEmpty ( " foo " ) );
72+ }
73+
6474 /**
6575 * <p>testIsBlank.</p>
6676 */
You can’t perform that action at this time.
0 commit comments