Top Description Inners Fields Constructors Methods
org.springframework.scheduling.support

pack-priv abstract Class CronField

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.scheduling.support.QuartzCronField, org.springframework.scheduling.support.BitsCronField, org.springframework.scheduling.support.CompositeCronField
Imports
java.time.DateTimeException, java.time.temporal.ChronoField, .ChronoUnit, .Temporal, .ValueRange, java.util.function.BiFunction, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils

Single field in a cron pattern. Created using the parse* methods, the main and only entry point is nextOrSame(Temporal).

Supports a Quartz day-of-month/week field with an L/# expression. Follows common cron conventions in every other respect, including 0-6 for SUN-SAT (plus 7 for SUN as well). Note that Quartz deviates from the day-of-week convention in cron through 1-7 for SUN-SAT whereas Spring strictly follows cron even in combination with the optional Quartz-specific L/# expressions.

Author
Arjen Poutsma
Since
5.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum
CronField.Type

Represents the type of cron field, i.e. seconds, minutes, hours, day-of-month, month, day-of-week.

Field Summary

Modifier and TypeField and Description
private static final String[]
private static final String[]
private final CronField.Type

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected static <T extends Temporal & Comparable<? super T>> T
cast(Temporal temporal)

public abstract <T extends Temporal & Comparable<? super T>> T

Returns:

the next or same temporal matching the pattern
nextOrSame
(T
the seed value
temporal
)

Get the next or same Temporal in the sequence matching this cron field.

public static CronField
parseDaysOfMonth(String value)

Parse the given value into a days of months CronField, the fourth entry of a cron expression.

public static CronField
parseDaysOfWeek(String value)

Parse the given value into a days of week CronField, the sixth entry of a cron expression.

public static CronField
parseHours(String value)

Parse the given value into an hours CronField, the third entry of a cron expression.

private static CronField
parseList(String value, CronField.Type type, BiFunction<String, CronField.Type, CronField> parseFieldFunction)

public static CronField
parseMinutes(String value)

Parse the given value into a minutes CronField, the second entry of a cron expression.

public static CronField
parseMonth(String value)

Parse the given value into a month CronField, the fifth entry of a cron expression.

public static CronField
parseSeconds(String value)

Parse the given value into a seconds CronField, the first entry of a cron expression.

private static String
replaceOrdinals(String value, String[] list)

protected CronField.Type
type()

public static CronField
zeroNanos()

Return a CronField enabled for 0 nanoseconds.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DAYSback to summary
private static final String[] DAYS
MONTHSback to summary
private static final String[] MONTHS
typeback to summary
private final CronField.Type type

Constructor Detail

CronFieldback to summary
protected CronField(CronField.Type type)

Method Detail

castback to summary
protected static <T extends Temporal & Comparable<? super T>> T cast(Temporal temporal)
Annotations
@SuppressWarnings:unchecked
nextOrSameback to summary
public abstract <T extends Temporal & Comparable<? super T>> T nextOrSame(T temporal)

Get the next or same Temporal in the sequence matching this cron field.

Parameters
temporal:T

the seed value

Returns:T

the next or same temporal matching the pattern

Annotations
@Nullable
parseDaysOfMonthback to summary
public static CronField parseDaysOfMonth(String value)

Parse the given value into a days of months CronField, the fourth entry of a cron expression.

parseDaysOfWeekback to summary
public static CronField parseDaysOfWeek(String value)

Parse the given value into a days of week CronField, the sixth entry of a cron expression.

parseHoursback to summary
public static CronField parseHours(String value)

Parse the given value into an hours CronField, the third entry of a cron expression.

parseListback to summary
private static CronField parseList(String value, CronField.Type type, BiFunction<String, CronField.Type, CronField> parseFieldFunction)
parseMinutesback to summary
public static CronField parseMinutes(String value)

Parse the given value into a minutes CronField, the second entry of a cron expression.

parseMonthback to summary
public static CronField parseMonth(String value)

Parse the given value into a month CronField, the fifth entry of a cron expression.

parseSecondsback to summary
public static CronField parseSeconds(String value)

Parse the given value into a seconds CronField, the first entry of a cron expression.

replaceOrdinalsback to summary
private static String replaceOrdinals(String value, String[] list)
typeback to summary
protected CronField.Type type()
zeroNanosback to summary
public static CronField zeroNanos()

Return a CronField enabled for 0 nanoseconds.

org.springframework.scheduling.support back to summary

protected final Enum CronField.Type

extends Enum<CronField.Type>
Class Inheritance

Represents the type of cron field, i.e. seconds, minutes, hours, day-of-month, month, day-of-week.

Field Summary

Modifier and TypeField and Description
public static final CronField.Type
public static final CronField.Type
private final ChronoField
private final ChronoUnit
public static final CronField.Type
private final ChronoField[]
public static final CronField.Type
public static final CronField.Type
public static final CronField.Type
public static final CronField.Type

Constructor Summary

AccessConstructor and Description
private
Type(ChronoField field, ChronoUnit higherOrder, ChronoField... lowerOrders)

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the value that was passed in
checkValidValue
(int
the value to check
value
)

Check whether the given value is valid, i.e. whether it falls in range.

public <
the type of temporal
T extends Temporal & Comparable<? super T>
>
T

Returns:

the elapsed temporal, typically with goal as value for this type.
elapseUntil
(T
the temporal to elapse
temporal
,
int
the goal value
goal
)

Elapse the given temporal for the difference between the current value of this field and the goal value.

public int

Returns:

the value of this type
get
(Temporal date)

Return the value of this type for the given temporal.

public ValueRange

Returns:

the range of this field
range
()

Return the general range of this type.

public <
the type of temporal
T extends Temporal
>
T

Returns:

the reset temporal
reset
(T
the temporal to reset
temporal
)

Reset this and all lower order fields of the given temporal to their minimum value.

public <
the type of temporal
T extends Temporal & Comparable<? super T>
>
T

Returns:

the rolled forward temporal
rollForward
(T
the temporal to roll forward
temporal
)

Roll forward the give temporal until it reaches the next higher order field.

public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.
public static CronField.Type
public static CronField.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

DAY_OF_MONTHback to summary
public static final CronField.Type DAY_OF_MONTH
DAY_OF_WEEKback to summary
public static final CronField.Type DAY_OF_WEEK
fieldback to summary
private final ChronoField field
higherOrderback to summary
private final ChronoUnit higherOrder
HOURback to summary
public static final CronField.Type HOUR
lowerOrdersback to summary
private final ChronoField[] lowerOrders
MINUTEback to summary
public static final CronField.Type MINUTE
MONTHback to summary
public static final CronField.Type MONTH
NANOback to summary
public static final CronField.Type NANO
SECONDback to summary
public static final CronField.Type SECOND

Constructor Detail

Typeback to summary
private Type(ChronoField field, ChronoUnit higherOrder, ChronoField... lowerOrders)

Method Detail

checkValidValueback to summary
public int checkValidValue(int value)

Check whether the given value is valid, i.e. whether it falls in range.

Parameters
value:int

the value to check

Returns:int

the value that was passed in

Exceptions
IllegalArgumentException:
if the given value is invalid
elapseUntilback to summary
public <T extends Temporal & Comparable<? super T>> T elapseUntil(T temporal, int goal)

Elapse the given temporal for the difference between the current value of this field and the goal value. Typically, the returned temporal will have the given goal as the current value for this type, but this is not the case for DAY_OF_MONTH.

Parameters
<T>
the type of temporal
temporal:T

the temporal to elapse

goal:int

the goal value

Returns:T

the elapsed temporal, typically with goal as value for this type.

getback to summary
public int get(Temporal date)

Return the value of this type for the given temporal.

Returns:int

the value of this type

rangeback to summary
public ValueRange range()

Return the general range of this type. For instance, this method will return 0-31 for MONTH.

Returns:ValueRange

the range of this field

resetback to summary
public <T extends Temporal> T reset(T temporal)

Reset this and all lower order fields of the given temporal to their minimum value. For instance for MINUTE, this method resets nanos, seconds, and minutes to 0.

Parameters
<T>
the type of temporal
temporal:T

the temporal to reset

Returns:T

the reset temporal

rollForwardback to summary
public <T extends Temporal & Comparable<? super T>> T rollForward(T temporal)

Roll forward the give temporal until it reaches the next higher order field. Calling this method is equivalent to calling elapseUntil(Temporal, int) with goal set to the minimum value of this field's range.

Parameters
<T>
the type of temporal
temporal:T

the temporal to roll forward

Returns:T

the rolled forward temporal

toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static CronField.Type valueOf(String name)
valuesback to summary
public static CronField.Type[] values()