为什么这里的get方法没有像keyword那样做空值判断呢?

来源:7-6 兴趣索引对象定义与服务实现

weixin_慕函数6469244

2023-11-27

兴趣的

    @Override
    public Set<Long> get(String key) {
        return itUnitMap.get(key);
    }

关键词的:

    @Override
    public Set<Long> get(String key) {

        /**
         * 如果key是空,返回空集合
         */
        if (StringUtils.isEmpty(key)) {
            return Collections.emptySet();
        }

        Set<Long> result = keywordUnitMap.get(key);
        if (result == null) {
            return Collections.emptySet();
        }

        return result;
    }
写回答

1回答

张勤一

2023-11-27

可以向上和向下追溯下代码的使用,看看是否有必要判空

1
0

Spring Cloud微服务架构 设计实现广告系统

广告营销系统,未来大中型企业的标配

2136 学习 · 927 问题

查看课程