|
12 | 12 | */ |
13 | 13 | package org.assertj.core.api; |
14 | 14 |
|
15 | | -import static java.lang.Character.isWhitespace; |
16 | 15 | import static org.assertj.core.api.Assertions.contentOf; |
17 | 16 | import static org.assertj.core.error.ShouldBeASCII.shouldBeASCII; |
18 | 17 | import static org.assertj.core.error.ShouldBeAlphabetic.shouldBeAlphabetic; |
@@ -205,10 +204,6 @@ private void assertNotBlank(CharSequence actual) { |
205 | 204 | if (isBlank(actual)) throw assertionError(shouldNotBeBlank(actual)); |
206 | 205 | } |
207 | 206 |
|
208 | | - private static boolean isBlank(CharSequence actual) { |
209 | | - return isNullOrEmpty(actual) || strictlyContainsWhitespaces(actual); |
210 | | - } |
211 | | - |
212 | 207 | /** |
213 | 208 | * Verifies that the actual {@code CharSequence} contains one or more whitespace characters (according to |
214 | 209 | * {@link Character#isWhitespace(char)}). |
@@ -334,10 +329,6 @@ private void assertDoesNotContainOnlyWhitespaces(CharSequence actual) { |
334 | 329 | if (containsOnlyWhitespaces(actual)) throw assertionError(shouldNotContainOnlyWhitespaces(actual)); |
335 | 330 | } |
336 | 331 |
|
337 | | - private static boolean containsOnlyWhitespaces(CharSequence actual) { |
338 | | - return !isNullOrEmpty(actual) && strictlyContainsWhitespaces(actual); |
339 | | - } |
340 | | - |
341 | 332 | /** |
342 | 333 | * Verifies that the actual {@code CharSequence} is blank, i.e. consists of one or more whitespace characters |
343 | 334 | * (according to {@link Character#isWhitespace(char)}). |
@@ -365,7 +356,7 @@ public SELF isJavaBlank() { |
365 | 356 | } |
366 | 357 |
|
367 | 358 | private void assertJavaBlank(CharSequence actual) { |
368 | | - if (!isJavaBlank(actual)) throw assertionError(shouldBeBlank(actual)); |
| 359 | + if (!containsOnlyWhitespaces(actual)) throw assertionError(shouldBeBlank(actual)); |
369 | 360 | } |
370 | 361 |
|
371 | 362 | /** |
@@ -396,15 +387,7 @@ public SELF isNotJavaBlank() { |
396 | 387 | } |
397 | 388 |
|
398 | 389 | private void assertNotJavaBlank(CharSequence actual) { |
399 | | - if (isJavaBlank(actual)) throw assertionError(shouldNotBeBlank(actual)); |
400 | | - } |
401 | | - |
402 | | - private static boolean isJavaBlank(CharSequence actual) { |
403 | | - if (isNullOrEmpty(actual)) return false; |
404 | | - for (int i = 0; i < actual.length(); i++) { |
405 | | - if (!isWhitespace(actual.charAt(i))) return false; |
406 | | - } |
407 | | - return true; |
| 390 | + if (containsOnlyWhitespaces(actual)) throw assertionError(shouldNotBeBlank(actual)); |
408 | 391 | } |
409 | 392 |
|
410 | 393 | /** |
@@ -2152,6 +2135,14 @@ public SELF isVisible() { |
2152 | 2135 | return myself; |
2153 | 2136 | } |
2154 | 2137 |
|
| 2138 | + private static boolean isBlank(CharSequence actual) { |
| 2139 | + return isNullOrEmpty(actual) || strictlyContainsWhitespaces(actual); |
| 2140 | + } |
| 2141 | + |
| 2142 | + private static boolean containsOnlyWhitespaces(CharSequence actual) { |
| 2143 | + return !isNullOrEmpty(actual) && strictlyContainsWhitespaces(actual); |
| 2144 | + } |
| 2145 | + |
2155 | 2146 | private static boolean isNullOrEmpty(CharSequence actual) { |
2156 | 2147 | return actual == null || actual.length() == 0; |
2157 | 2148 | } |
|
0 commit comments