1. Detailed explanation of the source code of the isEmpty method
Source code analysis: The above method shows that true is returned only when the string is not a null and non-empty string (""). isNotEmpty method is the opposite of isEmpty;
See the following official website example:
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
2. Detailed explanation of the source code of the isBlank method
Source code analysis: First, if the parameters passed in are null or empty strings, it will return true, and then use the Character.isWhitespace method to determine whether the characters are all blank characters (spaces, tab keys, line breaks), if so, return false, otherwise return true; isNotBlank method is the opposite of isBlank method;
Take a look at the example on the official website:
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false
3. isAnyBlank source code
Source code analysis: First, whether the parameter array is empty, if it is null, it returns false, if the array is non-empty, it determines whether each string in the array is a blank character, and returns true if there is a blank character; isNoneBlank identifies that none of the elements in the array are whitespace, as opposed to isAnyBlank;
4. isAllBlank source code analysis
Source code analysis: First, determine whether the parameter array is empty, if it is true, otherwise it will return false if one of the elements in the array is non-whitespace.
|