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;
            
        }

  • 相关阅读:
    Javascript 使用字符串
    JavaScript精简学习4(动态表单和链接处理)
    JavaScript 使用表单
    事半功倍之Javascript (2)
    jQuery隐藏按钮
    .NET线程同步之Interlocked和ReadWrite 锁线程同步——事件构造
    linux命令汇总
    好的设计能减少大量的工作
    Prism学习笔记
    编写C函数的技巧
  • 原文地址:https://www.cnblogs.com/huyanlon/p/7309758.html
Copyright © 2011-2022 走看看