JAVA使用Map去重

            List userList = JsonUtil.jsonToList(data,User.class);
            Map map = new HashMap<>(ValidationUtil.getHashMapValue(null));
            //处理重复数据
            for (User user :conditionsList) {
                if(map.containsKey(user.getCode())){
                    map.put(user.getCode(),oldCondition);
                }else{
                    map.put(user.getCode(),conditions);
                }
            }
            List newUserList = new ArrayList<>();
            if (ValidationUtil.isNotEmpty(map)){
                for (String key:map.keySet()) {
                    newUserList.add(map.get(key));
                }
            }

你可能感兴趣的:(JAVA使用Map去重)