有些时候,会根据key取值,对值进行操作后(加减等)判断。
如果value位是一个数值,一般会涉及到边界值0的判断,此时最好用getOrDefault
if (key.equals("research")) {
if ((dto.getTypePoints().getOrDefault(PointTypeEnum.RESEARCH.toString(),0.0) + dto.getTypePoints().getOrDefault(PointTypeEnum.AID_RESEARCH.toString(),0.0)
>= dto.getNewNeedPoints().get(key) - requiredBachelorPoints)
&&
(dto.getGraduationPoints() >= dto.getNewNeedPoints().get(key)) ) {
dto.setCanGraduate(1);
}
}