Consistent hasText checks for CharSequence vs String

Directly inlined hasLength implementations for proper nullability detection in IntelliJ, assuming a hasText checked value is never null afterwards. Since the JVM is going to do this at runtime anyway, this is effectively equivalent but more indicative for source code introspection algorithms.

Issue: SPR-15540
This commit is contained in:
Juergen Hoeller 2017-10-24 13:16:47 +02:00
parent 9efdadcdca
commit 2d0ab4740c
1 changed files with 2 additions and 2 deletions

View File

@ -139,7 +139,7 @@ public abstract class StringUtils {
* @see Character#isWhitespace
*/
public static boolean hasText(@Nullable CharSequence str) {
return (hasLength(str) && containsText(str));
return (str != null && str.length() > 0 && containsText(str));
}
/**
@ -153,7 +153,7 @@ public abstract class StringUtils {
* @see #hasText(CharSequence)
*/
public static boolean hasText(@Nullable String str) {
return (hasLength(str) && containsText(str));
return (str != null && !str.isEmpty() && containsText(str));
}
private static boolean containsText(CharSequence str) {