@@ -247,26 +247,26 @@ public static String trimWhitespace(String str) {
247
247
/**
248
248
* Trim <em>all</em> whitespace from the given {@code CharSequence}:
249
249
* leading, trailing, and in between characters.
250
- * @param text the {@code CharSequence} to check
250
+ * @param str the {@code CharSequence} to check
251
251
* @return the trimmed {@code CharSequence}
252
252
* @since 5.3.22
253
253
* @see #trimAllWhitespace(String)
254
254
* @see java.lang.Character#isWhitespace
255
255
*/
256
- public static CharSequence trimAllWhitespace (CharSequence text ) {
257
- if (!hasLength (text )) {
258
- return text ;
256
+ public static CharSequence trimAllWhitespace (CharSequence str ) {
257
+ if (!hasLength (str )) {
258
+ return str ;
259
259
}
260
260
261
- int len = text .length ();
262
- StringBuilder sb = new StringBuilder (text .length ());
261
+ int len = str .length ();
262
+ StringBuilder sb = new StringBuilder (str .length ());
263
263
for (int i = 0 ; i < len ; i ++) {
264
- char c = text .charAt (i );
264
+ char c = str .charAt (i );
265
265
if (!Character .isWhitespace (c )) {
266
266
sb .append (c );
267
267
}
268
268
}
269
- return sb . toString () ;
269
+ return sb ;
270
270
}
271
271
272
272
/**
@@ -278,9 +278,10 @@ public static CharSequence trimAllWhitespace(CharSequence text) {
278
278
* @see java.lang.Character#isWhitespace
279
279
*/
280
280
public static String trimAllWhitespace (String str ) {
281
- if (str == null ) {
282
- return null ;
281
+ if (! hasLength ( str ) ) {
282
+ return str ;
283
283
}
284
+
284
285
return trimAllWhitespace ((CharSequence ) str ).toString ();
285
286
}
286
287
0 commit comments