public class ObjectUtilsTest {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        Set<String> set = new HashSet<>();
        Map<String, String> map = new HashMap<>();
        Integer[] arr = {};
        Integer integer = null;
        String str1 = null;
        String str2 = "";
        String str3 = "s";
        System.out.println("list = " + ObjectUtils.isEmpty(list));
        System.out.println("set = " + ObjectUtils.isEmpty(set));
        System.out.println("map = " + ObjectUtils.isEmpty(map));
        System.out.println("arr = " + ObjectUtils.isEmpty(arr));
        System.out.println("integer = " + ObjectUtils.isEmpty(integer));
        System.out.println("str1 = " + ObjectUtils.isEmpty(str1));
        System.out.println("str2 = " + ObjectUtils.isEmpty(str2));
        System.out.println("str3 = " + ObjectUtils.isEmpty(str3));
    }
}
list = true
set = true
map = true
arr = true
integer = true
str1 = true
str2 = true
str3 = false
请问这种情况下,stringutils.isblank 的意义在哪里呢,,,
感觉处理,只判断 string=""时,需要用到 stringutils.isempty
stringutils.isblank 的存在意义,被 ObjectUtils.isEmpty 全部压住了
|  |      1JsonNode      2021-12-22 12:10:01 +08:00 Checks if a String is whitespace, empty ("") or null. | 
|  |      2gadfly3173      2021-12-22 12:20:37 +08:00 首先 blank 最主要是判断字符串是不是全是空格,其次这种名字的 Util 这么多,不如先说说这是哪个包里的。。。 | 
|  |      3RedBeanIce OP @lovedoing 我无法理解回复的意思,我只能理解到是在回答 stringutils.isblank 的功能。 可是问题的原意是,stringutils.isblank 的存在意义,ObjectUtils.isEmpty 完全可以做到 stringutils.isblank 的功能 | 
|  |      4RedBeanIce OP @gadfly3173 spring 自带 | 
|      5GM      2021-12-22 12:24:07 +08:00 ``` isBlank(" ") == true; isEmpty(" ") == false; ``` | 
|  |      6RedBeanIce OP 我懂了,,又是一个傻子般的问题。 | 
|  |      7RedBeanIce OP 问问题应该先看源码的,犯了提问的艺术的错误 | 
|  |      8monetto      2021-12-22 12:31:09 +08:00 其他的就不说了,补充一点,语义化作用。 StringUtils 会让人联想到 String 的一些判断逻辑。 而 ObjectUtil 给人感觉更是通用的一些逻辑,会让人反应一秒,或者需要点进源码里看一看。 | 
|  |      9gadfly3173      2021-12-22 16:59:42 +08:00 @RedBeanIce #4 spring 自带的 isBlank 应该是被废弃的吧。。。现在是用 hasText 和 hasLength 代替 |