CollectionssortretListComparatorcomparingDrugBatchStockVO getExpireDatethenComparingDrugBatchStockVO getBatchNo;代码意义
这段代码的意义是对retList列表中的元素进行排序。排序规则是首先按照DrugBatchStockVO对象的expireDate属性进行升序排序,如果expireDate相同,则按照batchNo属性进行升序排序。
具体实现是通过调用Collections类的sort方法,传入一个Comparator对象作为参数。Comparator.comparing方法用于创建一个比较器,指定按照expireDate属性进行比较。然后使用thenComparing方法,再指定按照batchNo属性进行比较。最终,sort方法会根据这个比较器对retList进行排序。
原文地址: https://www.cveoy.top/t/topic/iG7b 著作权归作者所有。请勿转载和采集!