Enum Class CronField
- All Implemented Interfaces:
Serializable, Comparable<CronField>, Constable
Cron Field Definition - Enum for Cron Expression Fields
Cron字段定义 - Cron表达式字段枚举
Defines the valid range, display name, and name aliases for each cron field. Handles case-insensitive alias resolution (MON→1, JAN→1, etc.).
定义每个Cron字段的有效范围、显示名称和名称别名。 处理不区分大小写的别名解析(MON→1、JAN→1等)。
Features | 主要功能:
- Range validation per field - 每字段范围校验
- Month aliases: JAN-DEC → 1-12 - 月份别名
- Day-of-week aliases: SUN-SAT → 0-6 - 星期别名
- Case-insensitive alias resolution - 不区分大小写别名解析
Security | 安全性:
- Thread-safe: Yes (immutable enum) - 线程安全: 是(不可变枚举)
Usage Examples | 使用示例:
// Access cron field properties
// 访问cron字段属性
CronField field = CronField.HOUR;
int min = field.min(); // 0
int max = field.max(); // 23
boolean valid = field.isValid(15); // true
- Since:
- JDK 25, opencode-base-cron V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDay of month field (1-31) 月中日字段(1-31)Day of week field (0-6, SUN=0) 星期字段(0-6,SUN=0)Hours field (0-23) 小时字段(0-23)Minutes field (0-59) 分钟字段(0-59)Month field (1-12) 月份字段(1-12)Seconds field (0-59) 秒字段(0-59) -
Method Summary
Modifier and TypeMethodDescriptionGets the display name of this field 获取此字段的显示名称booleanisInRange(int value) Checks if the given value is within the valid range 检查给定值是否在有效范围内intmax()Gets the maximum value 获取最大值intmin()Gets the minimum value 获取最小值resolveAliases(String field) Resolves name aliases in a field string (case-insensitive) 解析字段字符串中的名称别名(不区分大小写)static CronFieldReturns the enum constant of this class with the specified name.static CronField[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SECOND
Seconds field (0-59) 秒字段(0-59) -
MINUTE
Minutes field (0-59) 分钟字段(0-59) -
HOUR
Hours field (0-23) 小时字段(0-23) -
DAY_OF_MONTH
Day of month field (1-31) 月中日字段(1-31) -
MONTH
Month field (1-12) 月份字段(1-12) -
DAY_OF_WEEK
Day of week field (0-6, SUN=0) 星期字段(0-6,SUN=0)
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
displayName
Gets the display name of this field 获取此字段的显示名称- Returns:
- the display name | 显示名称
-
min
public int min()Gets the minimum value 获取最小值- Returns:
- the minimum | 最小值
-
max
public int max()Gets the maximum value 获取最大值- Returns:
- the maximum | 最大值
-
resolveAliases
Resolves name aliases in a field string (case-insensitive) 解析字段字符串中的名称别名(不区分大小写)Replaces aliases like MON, TUE, JAN, FEB with their numeric values. Handles aliases within ranges and lists (e.g., "MON-FRI" becomes "1-5").
将 MON、TUE、JAN、FEB 等别名替换为数字值。 处理范围和列表中的别名(例如 "MON-FRI" 变为 "1-5")。
- Parameters:
field- the field string | 字段字符串- Returns:
- the resolved field string | 解析后的字段字符串
-
isInRange
public boolean isInRange(int value) Checks if the given value is within the valid range 检查给定值是否在有效范围内- Parameters:
value- the value to check | 要检查的值- Returns:
- true if valid | 如果有效返回true
-