This commit is contained in:
Looly 2022-03-27 20:11:38 +08:00
parent 5966dcc626
commit 4cee9ba129
4 changed files with 36 additions and 8 deletions

View File

@ -4,6 +4,7 @@ import cn.hutool.core.builder.Builder;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
public class CronPatternBuilder implements Builder<String> { public class CronPatternBuilder implements Builder<String> {
private static final long serialVersionUID = 1L;
final String[] parts = new String[7]; final String[] parts = new String[7];

View File

@ -9,8 +9,10 @@ import cn.hutool.core.lang.Matcher;
* @author Looly * @author Looly
*/ */
public interface PartMatcher extends Matcher<Integer> { public interface PartMatcher extends Matcher<Integer> {
/** /**
* 获取指定值之后的匹配值也可以是指定值本身 * 获取指定值之后的匹配值也可以是指定值本身
*
* @param value 指定的值 * @param value 指定的值
* @return 匹配到的值或之后的值 * @return 匹配到的值或之后的值
*/ */

View File

@ -8,7 +8,11 @@ import java.util.Calendar;
import java.util.TimeZone; import java.util.TimeZone;
/** /**
* 单一表达式的匹配器匹配器由7个{@link PartMatcher}组成 * 单一表达式的匹配器匹配器由7个{@link PartMatcher}组成分别是
* <pre>
* 0 1 2 3 4 5 6
* SECOND MINUTE HOUR DAY_OF_MONTH MONTH DAY_OF_WEEK YEAR
* </pre>
* *
* @author looly * @author looly
* @since 5.8.0 * @since 5.8.0
@ -17,6 +21,17 @@ public class PatternMatcher {
private final PartMatcher[] matchers; private final PartMatcher[] matchers;
/**
* 构造
*
* @param secondMatcher 秒匹配器
* @param minuteMatcher 分匹配器
* @param hourMatcher 时匹配器
* @param dayOfMonthMatcher 日匹配器
* @param monthMatcher 月匹配器
* @param dayOfWeekMatcher 周匹配器
* @param yearMatcher 年匹配器
*/
public PatternMatcher(PartMatcher secondMatcher, public PatternMatcher(PartMatcher secondMatcher,
PartMatcher minuteMatcher, PartMatcher minuteMatcher,
PartMatcher hourMatcher, PartMatcher hourMatcher,
@ -38,6 +53,7 @@ public class PatternMatcher {
/** /**
* 根据表达式位置获取对应的{@link PartMatcher} * 根据表达式位置获取对应的{@link PartMatcher}
*
* @param part 表达式位置 * @param part 表达式位置
* @return {@link PartMatcher} * @return {@link PartMatcher}
*/ */
@ -46,6 +62,7 @@ public class PatternMatcher {
} }
//region match //region match
/** /**
* 给定时间是否匹配定时任务表达式 * 给定时间是否匹配定时任务表达式
* *
@ -85,6 +102,7 @@ public class PatternMatcher {
//endregion //endregion
//region nextMatchAfter //region nextMatchAfter
/** /**
* 获取下一个匹配日期时间 * 获取下一个匹配日期时间
* *

View File

@ -1,5 +1,12 @@
/** /**
* 定时任务表达式匹配器内部使用 * 定时任务表达式匹配器内部使用<br>
* 单一表达式使用{@link cn.hutool.cron.pattern.matcher.PatternMatcher}表示<br>
* {@link cn.hutool.cron.pattern.matcher.PatternMatcher}由7个{@link cn.hutool.cron.pattern.matcher.PartMatcher}组成
* 分别表示定时任务表达式中的7个位置:
* <pre>
* 0 1 2 3 4 5 6
* SECOND MINUTE HOUR DAY_OF_MONTH MONTH DAY_OF_WEEK YEAR
* </pre>
* *
* @author looly * @author looly
* *