当前位置: 首页 > news >正文

关于集合遇到的坑

 public void invoke(ComparisonSpotEvaluationResultsExcel comparisonSpotEvaluationResultsExcel, AnalysisContext analysisContext) {/*** 记录行号码*/ReadRowHolder readRowHolder = analysisContext.readRowHolder();Integer rowIndex = readRowHolder.getRowIndex();String row = "第 " + (rowIndex + 1) + " 行,";DetectionIndexServiceImpl.CheckResult error = new DetectionIndexServiceImpl.CheckResult();if (comparisonSpotEvaluationResultsExcel.getTbbh() == null || comparisonSpotEvaluationResultsExcel.getTbbh().equals("")) {error.setTableLocation(row);error.setErrorMessage("图斑编号为空");errors.add(error);}if (comparisonSpotEvaluationResultsExcel.getTbbh2() == null || comparisonSpotEvaluationResultsExcel.getTbbh2().equals("")) {error.setErrorMessage("转换图斑编号为空");error.setTableLocation(row);errors.add(error);}if (comparisonSpotEvaluationResultsExcel.getProvince() == null || comparisonSpotEvaluationResultsExcel.getProvince().equals("")){error.setErrorMessage("省份为空");error.setTableLocation(row);errors.add(error);}if (comparisonSpotEvaluationResultsExcel.getCity() == null || comparisonSpotEvaluationResultsExcel.getCity().equals("")) {error.setErrorMessage("地市为空");error.setTableLocation(row);errors.add(error);}if (comparisonSpotEvaluationResultsExcel.getDistrict() == null || comparisonSpotEvaluationResultsExcel.getDistrict().equals("")) {error.setErrorMessage("区县为空");error.setTableLocation(row);errors.add(error);}if(comparisonSpotEvaluationResultsExcel.getGrade()==null){error.setErrorMessage("矿山(图斑)污染评分等级为空");error.setTableLocation(row);errors.add(error);}ComparisonSpotEvaluationResults results = new ComparisonSpotEvaluationResults();BeanUtil.copyProperties(comparisonSpotEvaluationResultsExcel, results);results.setType(type);// 、、、r.add(results);}

原本想省劲儿只创建一个error,然后将该轮循环收集到错误放到集合里,然后就出现了每一行都是同一个错误提示。后来我又做了个小测试,发现确实会覆盖原来的,推断集合里存的是对象的引用地址。在这里插入图片描述

http://www.lryc.cn/news/211543.html

相关文章:

  • 需要下微信视频号视频的小伙伴们看过来~
  • 测试工具:hurl
  • RateLimiter限流
  • PMP适合哪些人去考?
  • 钡铼技术 工控机中的X86和ARM处理器:哪个更具可扩展性?
  • 软考 系统架构设计师系列知识点之软件构件(3)
  • 中科驭数亮相2023中国移动全球合作伙伴大会
  • WebGIS国产化(信创)研发流程一:数据库的调研与介绍
  • [Shell] ${} 的多种用法
  • 基于SpringBoot的社区医院管理系统设计与实现
  • Spring的执行流程与Bean的生命周期
  • 使用 SQL 的方式查询消息队列数据以及踩坑指南
  • 拿下国家级信创认证 中科驭数KPU SWIFT-2200N成为国内首款满足金融业严苛要求的DPU产品
  • centos怎么禁用和关闭selinux
  • 【LeetCode刷题日志】88.合并两个有序数组
  • 计算机考研 | 2013年 | 计算机组成原理真题
  • [Unity][VR]透视开发系列4-解决只看得到Passthrough但看不到Unity对象的问题
  • 电气工程 自动化 机械工科学生来看看
  • NewStarCTF2023week4-midsql(利用二分查找实现时间盲注攻击)
  • null,undefined的区别?
  • 2.flink编码第一步(maven工程创建)
  • Unit1_1:分治问题之时间复杂度求解
  • React hooks的闭包陷阱
  • 20.3 OpenSSL 对称AES加解密算法
  • 一文详解防御DDoS攻击的几大有效办法
  • Python二级 每周练习题24
  • MySQL - Buffer Pool
  • c++ 拆分函数返回值和参数类型
  • Ubuntu 23.10安装TeXlive并安装CTEX中文支持
  • SpringBoot中CommandLineRunner详解(含源码)