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:
parent
9efdadcdca
commit
2d0ab4740c
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue