File tree 2 files changed +17
-12
lines changed
main/java/org/codehaus/plexus/util
test/java/org/codehaus/plexus/util
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 )
156
156
}
157
157
158
158
/**
159
- * <p>
160
159
* Checks if a String is non <code>null</code> and is not empty (<code>length > 0</code>).
161
- * </p>
162
160
*
163
161
* @param str the String to check
164
162
* @return true if the String is non-null, and not length zero
@@ -169,21 +167,18 @@ public static boolean isNotEmpty( String str )
169
167
}
170
168
171
169
/**
170
+ * Checks if a String is <code>null</code> or empty.
172
171
* <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 only whitespace characters.
180
175
*
181
176
* @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
183
178
*/
184
179
public static boolean isEmpty ( String str )
185
180
{
186
- return ( ( str == null ) || ( str .trim (). isEmpty () ) );
181
+ return ( ( str == null ) || ( str .isEmpty () ) );
187
182
}
188
183
189
184
/**
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ public void testIsEmpty()
43
43
{
44
44
assertEquals ( true , StringUtils .isEmpty ( null ) );
45
45
assertEquals ( true , StringUtils .isEmpty ( "" ) );
46
- assertEquals ( true , StringUtils .isEmpty ( " " ) );
46
+ assertEquals ( false , StringUtils .isEmpty ( " " ) );
47
47
assertEquals ( false , StringUtils .isEmpty ( "foo" ) );
48
48
assertEquals ( false , StringUtils .isEmpty ( " foo " ) );
49
49
}
@@ -61,6 +61,16 @@ public void testIsNotEmpty()
61
61
assertEquals ( true , StringUtils .isNotEmpty ( " foo " ) );
62
62
}
63
63
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
+
64
74
/**
65
75
* <p>testIsBlank.</p>
66
76
*/
You can’t perform that action at this time.
0 commit comments