Record Class CronExplanation
java.lang.Object
java.lang.Record
cloud.opencode.base.cron.CronExplanation
- Record Components:
expression- the original cron expression string | 原始Cron表达式字符串description- a human-readable description of the expression | 表达式的人类可读描述nextExecutions- the upcoming execution times (unmodifiable) | 即将到来的执行时间(不可修改)estimatedInterval- the estimated interval between consecutive executions | 连续执行之间的预估间隔
- All Implemented Interfaces:
Serializable
public record CronExplanation(String expression, String description, List<ZonedDateTime> nextExecutions, Duration estimatedInterval)
extends Record
implements Serializable
Cron Explanation - One-Stop Debugging Info Container for Cron Expressions
Cron解释 - Cron表达式的一站式调试信息容器
An immutable record that bundles together all the information needed to understand and debug a cron expression: the original expression string, a human-readable description, upcoming execution times, and the estimated interval between executions.
一个不可变记录,将理解和调试Cron表达式所需的所有信息捆绑在一起: 原始表达式字符串、人类可读描述、即将到来的执行时间以及执行之间的预估间隔。
Features | 主要功能:
- Immutable and thread-safe (Java record) - 不可变且线程安全(Java记录)
- Unmodifiable next-executions list - 不可修改的下次执行列表
- Formatted multi-line toString() for debugging - 格式化的多行toString()用于调试
- Serializable for transport/storage - 可序列化用于传输/存储
Usage Examples | 使用示例:
CronExpression expr = CronExpression.parse("0 9 * * MON-FRI");
ZonedDateTime now = ZonedDateTime.now();
CronExplanation explanation = new CronExplanation(
expr.getExpression(),
expr.describe(),
expr.nextExecutions(now, 5),
Duration.ofHours(24)
);
System.out.println(explanation);
// Expression : 0 9 * * MON-FRI
// Description: At 09:00, Monday through Friday
// Interval : PT24H
// Next executions:
// 1. 2026-04-03T09:00:00+08:00[Asia/Shanghai]
// 2. 2026-04-06T09:00:00+08:00[Asia/Shanghai]
// ...
Security | 安全性:
- Thread-safe: Yes (immutable record with defensive copy) - 线程安全: 是(不可变记录,防御性拷贝)
- Null-safe: Yes (rejects null inputs) - 空值安全: 是
- Since:
- JDK 25, opencode-base-cron V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCronExplanation(String expression, String description, List<ZonedDateTime> nextExecutions, Duration estimatedInterval) Compact constructor — validates inputs and creates a defensive copy of the list. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theestimatedIntervalrecord component.Returns the value of theexpressionrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of thenextExecutionsrecord component.toString()Returns a nicely formatted multi-line debug output.
-
Constructor Details
-
CronExplanation
public CronExplanation(String expression, String description, List<ZonedDateTime> nextExecutions, Duration estimatedInterval) Compact constructor — validates inputs and creates a defensive copy of the list. 紧凑构造器 — 验证输入并创建列表的防御性拷贝。
-
-
Method Details
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
expression
Returns the value of theexpressionrecord component.- Returns:
- the value of the
expressionrecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
nextExecutions
Returns the value of thenextExecutionsrecord component.- Returns:
- the value of the
nextExecutionsrecord component
-
estimatedInterval
Returns the value of theestimatedIntervalrecord component.- Returns:
- the value of the
estimatedIntervalrecord component
-