zoukankan      html  css  js  c++  java
  • list对象 利用Map去除对象中字段的重复

        public List<HostelMessageApi> hosteApi(HostelMessageApi host){
            String appid = host.getAppno();
            EMNewStudent student = new EMNewStudent();
            //创建空对象,进行对象添加
            List<HostelMessageApi> listHost = new ArrayList<HostelMessageApi>();
            //给EMNewStudent对象添加appno
            student.setAppno(appid);
            List<EMNewStudent> list = dormitoryFeesApiDao.dormitoryList(student);
            if(list.size()!=0){
                Map<String,EMNewStudent> map=new HashMap<>();
                for (EMNewStudent emNewStudent : list) {
                    String key=emNewStudent.getMajor().getDorm().getQuarterage().getDictionary().getName();
                    if(!map.containsKey(key)){
                        map.put(key, emNewStudent);
                    }
                    
                }
                for (String key : map.keySet()) {
                    EMNewStudent em=map.get(key);
                    HostelMessageApi hostList = new HostelMessageApi();
                    hostList.setDormfeename(em.getMajor().getDorm().getQuarterage().getDictionary().getName());//房型
                    hostList.setFeesum(em.getMajor().getDorm().getQuarterage().getDormfeeprice());//费用金额
                    hostList.setFeeid(em.getMajor().getDorm().getQuarterage().getDormfeeInfo_id());//费用id
                    listHost.add(hostList);
                }
            }
            return listHost;
            
        }

  • 相关阅读:
    服务器端和客户端有什么区别
    在 CSS 中,width 和 height 指的是内容区域的宽度和高度
    弹出框
    cdn 查询库
    超链接 a的小手
    jsonk可以传递boolean
    list,set中可以存放Object类型对象
    $("p").click();触发每一个匹配元素的click事件
    jquery选择器中的逗号
    <input type="text" onfocus="func();" onblur="func1();"/>
  • 原文地址:https://www.cnblogs.com/huyanlon/p/7309758.html
Copyright © 2011-2022 走看看