记录一次使用 Comparator排序
if (ewbLimitList.size() > 0) { Collections.sort(ewbLimitList, new Comparator<EwbLimitVO>() { /** * 返回负数表示:o1大于o2 * 返回 0 表示:o1和o2相等 * 返回正数表示:o1小于o2 * @param o1 * @param o2 * @return */ @Override public int compare(EwbLimitVO o1, EwbLimitVO o2) { if (o1.getSendTypeId() > o2.getSendTypeId()) { return -1; } if (o1.getSendTypeId().equals(o2.getSendTypeId())) { if (o1.getDispatchTypeId() > o2.getDispatchTypeId()) { return -1; } } return 1; } }); if (ewbLimitList.get(0).getWeightMinimum() <= caclWeight && caclWeight <= ewbLimitList.get(0).getWeightMaximum()) { return null; } return ewbLimitList.get(0);