Object的equals方法容易抛空指针异常,用java8的Objects.equals替换

This commit is contained in:
liuhuan
2019-12-28 18:58:10 +08:00
parent 3eedc8a761
commit 0a915248fc
11 changed files with 28 additions and 41 deletions

View File

@@ -2,6 +2,8 @@ package cn.hutool.cron.pattern.parser;
import cn.hutool.cron.CronException;
import java.util.Objects;
/**
* 每月的几号值处理<br>
* 每月最多31天32和“L”都表示最后一天
@@ -17,7 +19,7 @@ public class DayOfMonthValueParser extends SimpleValueParser {
@Override
public int parse(String value) throws CronException {
if (value.equalsIgnoreCase("L") || value.equals("32")) {// 每月最后一天
if ("L".equalsIgnoreCase(value) || Objects.equals("32",value)) {// 每月最后一天
return 32;
} else {
return super.parse(value);

View File

@@ -38,7 +38,7 @@ public class DayOfWeekValueParser extends SimpleValueParser {
* @throws CronException 无效别名抛出此异常
*/
private int parseAlias(String value) throws CronException {
if(value.equalsIgnoreCase("L")){
if("L".equalsIgnoreCase(value)){
//最后一天为星期六
return ALIASES.length - 1;
}