天天看点

两个List合并的问题

public class PersonConfigVO {
    /**
     * 配置项唯一id
     */
    private String id;
    /**
     * 排序号
     */
    private Integer sort;
    /**
     * 描述信息
     */
    private String label;
    /**
     * 图标
     */
    private String icon;
    /**
     * 开关
     */
    private Boolean isActive;
}      
List<PersonConfigVO> list1 = JSON.parseArray(configEntity.getMenuField(), PersonConfigVO.class);
                List<PersonConfigVO> list2 = JSON.parseArray(systemConfig.getValue(), PersonConfigVO.class);
                Map<String, PersonConfigVO> map = new HashMap<>(8);
                for (PersonConfigVO configVO : list2) {
                    map.put(configVO.getId(), configVO);
                }
                for (PersonConfigVO configVO : list1) {
                    map.put(configVO.getId(), configVO);
                }
                List<PersonConfigVO> result=new ArrayList<>();
                for(Map.Entry<String,PersonConfigVO> configVOEntry: map.entrySet()){
                    result.add(configVOEntry.getValue());
                }