List of utility methods to do String Empty Check
boolean | isEmpty(String string) is Empty if (string == null) { return true; if ("".equals(string)) { return true; return false; |
boolean | isEmptyString(String s) is Empty String return s.trim().length() == 0;
|
boolean | isEmptyOrNull(String str) is Empty Or Null return str == null || str.length() == 0 || str.contentEquals("null") || str.trim().equals(""); |
String | toNullIfEmptyOrWhitespace(String string) Returns the given string if it is nonempty and contains at least one non-whitespace character; null otherwise. return isEmptyOrWhitespace(string) ? null : string;
|
String | toNullIfEmpty(String string) Old location of Strings#emptyToNull ; this method will be deprecated soon. return Strings.emptyToNull(string);
|
boolean | isNullOrEmptyOrOnlyWhitespaces(String string) Checks is string null or its length == 0 or it contains only whitespaces, very useful return isNullOrEmpty(string) ? true : string.trim().length() == 0;
|
String | nullToEmpty(String url) Use to normalize URL parameters by returning empty string instead of null or "null". if (null == url || url.equals(NULL)) return EMPTY; return url; |
boolean | isEmpty(String s) Check if string is null or empty. if (null == s || s.trim().equals(EMPTY) || s.trim().equals(NULL)) return true; return false; |
boolean | isEmpty(String s) Implement an isEmpty for API < 9 return s == null || s.length() == 0;
|
boolean | isEmpty(String str) is Empty return str == null || str.length() == 0;
|