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

pack-priv final Class QuartzCronField

extends CronField
Class Inheritance
Imports
java.time.DateTimeException, .DayOfWeek, java.time.temporal.ChronoField, .ChronoUnit, .Temporal, .TemporalAdjuster, .TemporalAdjusters, org.springframework.lang.Nullable, org.springframework.util.Assert

Extension of CronField for Quartz-specific fields. Created using the parse* methods, uses a TemporalAdjuster internally.

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

Field Summary

Modifier and TypeField and Description
private final TemporalAdjuster
private final CronField.Type
private final String

Constructor Summary

AccessConstructor and Description
private
private
QuartzCronField(CronField.Type type, CronField.Type rollForwardType, TemporalAdjuster adjuster, String value)

Constructor for fields that need to roll forward over a different type than the type this field represents.

Method Summary

Modifier and TypeMethod and Description
private <T extends Temporal & Comparable<? super T>> T
adjust(T temporal)

private static TemporalAdjuster
atMidnight()

Returns an adjuster that resets to midnight.

private static TemporalAdjuster
dayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek)

Returns a temporal adjuster that finds ordinal-th occurrence of the given day-of-week in a month.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public static boolean
isQuartzDaysOfMonthField(String value)

Determine whether the given value is a Quartz day-of-month field.

public static boolean
isQuartzDaysOfWeekField(String value)

Determine whether the given value is a Quartz day-of-week field.

private static boolean
isWeekday(DayOfWeek dayOfWeek)

private static TemporalAdjuster
lastDayOfMonth()

Returns an adjuster that returns a new temporal set to the last day of the current month at midnight.

private static TemporalAdjuster

Returns:

a nth-to-last day-of-month adjuster
lastDayWithOffset
(int
the negative offset, i.e. -3 means third-to-last
offset
)

Returns a temporal adjuster that finds the nth-to-last day of the month.

private static TemporalAdjuster
lastInMonth(DayOfWeek dayOfWeek)

Returns a temporal adjuster that finds the last of the given day-of-week in a month.

private static TemporalAdjuster
lastWeekdayOfMonth()

Returns an adjuster that returns the last weekday of the month.

public <T extends Temporal & Comparable<? super T>> T
nextOrSame(T
the seed value
temporal
)

Implements abstract org.springframework.scheduling.support.CronField.nextOrSame.

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

private static DayOfWeek
public static QuartzCronField
parseDaysOfMonth(String value)

Hides org.springframework.scheduling.support.CronField.parseDaysOfMonth.

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

public static QuartzCronField
parseDaysOfWeek(String value)

Hides org.springframework.scheduling.support.CronField.parseDaysOfWeek.

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

private static Temporal
rollbackToMidnight(Temporal current, Temporal result)

Rolls back the given result to midnight.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private static TemporalAdjuster

Returns:

the weekday-nearest-to adjuster
weekdayNearestTo
(int
the goal day-of-month
dayOfMonth
)

Returns a temporal adjuster that finds the weekday nearest to the given day-of-month.

Inherited from org.springframework.scheduling.support.CronField:
castparseHoursparseMinutesparseMonthparseSecondstypezeroNanos

Field Detail

adjusterback to summary
private final TemporalAdjuster adjuster
rollForwardTypeback to summary
private final CronField.Type rollForwardType
valueback to summary
private final String value

Constructor Detail

QuartzCronFieldback to summary
private QuartzCronField(CronField.Type type, TemporalAdjuster adjuster, String value)
QuartzCronFieldback to summary
private QuartzCronField(CronField.Type type, CronField.Type rollForwardType, TemporalAdjuster adjuster, String value)

Constructor for fields that need to roll forward over a different type than the type this field represents. See parseDaysOfWeek(String).

Method Detail

adjustback to summary
private <T extends Temporal & Comparable<? super T>> T adjust(T temporal)
Annotations
@Nullable
@SuppressWarnings:unchecked
atMidnightback to summary
private static TemporalAdjuster atMidnight()

Returns an adjuster that resets to midnight.

dayOfWeekInMonthback to summary
private static TemporalAdjuster dayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek)

Returns a temporal adjuster that finds ordinal-th occurrence of the given day-of-week in a month.

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isQuartzDaysOfMonthFieldback to summary
public static boolean isQuartzDaysOfMonthField(String value)

Determine whether the given value is a Quartz day-of-month field.

isQuartzDaysOfWeekFieldback to summary
public static boolean isQuartzDaysOfWeekField(String value)

Determine whether the given value is a Quartz day-of-week field.

isWeekdayback to summary
private static boolean isWeekday(DayOfWeek dayOfWeek)
lastDayOfMonthback to summary
private static TemporalAdjuster lastDayOfMonth()

Returns an adjuster that returns a new temporal set to the last day of the current month at midnight.

lastDayWithOffsetback to summary
private static TemporalAdjuster lastDayWithOffset(int offset)

Returns a temporal adjuster that finds the nth-to-last day of the month.

Parameters
offset:int

the negative offset, i.e. -3 means third-to-last

Returns:TemporalAdjuster

a nth-to-last day-of-month adjuster

lastInMonthback to summary
private static TemporalAdjuster lastInMonth(DayOfWeek dayOfWeek)

Returns a temporal adjuster that finds the last of the given day-of-week in a month.

lastWeekdayOfMonthback to summary
private static TemporalAdjuster lastWeekdayOfMonth()

Returns an adjuster that returns the last weekday of the month.

nextOrSameback to summary
public <T extends Temporal & Comparable<? super T>> T nextOrSame(T temporal)

Implements abstract org.springframework.scheduling.support.CronField.nextOrSame.

Doc from org.springframework.scheduling.support.CronField.nextOrSame.

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
@Override
parseDayOfWeekback to summary
private static DayOfWeek parseDayOfWeek(String value)
parseDaysOfMonthback to summary
public static QuartzCronField parseDaysOfMonth(String value)

Hides org.springframework.scheduling.support.CronField.parseDaysOfMonth.

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

Expects a "L" or "W" in the given value.

parseDaysOfWeekback to summary
public static QuartzCronField parseDaysOfWeek(String value)

Hides org.springframework.scheduling.support.CronField.parseDaysOfWeek.

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

Expects a "L" or "#" in the given value.

rollbackToMidnightback to summary
private static Temporal rollbackToMidnight(Temporal current, Temporal result)

Rolls back the given result to midnight. When current has the same day of month as result, the former is returned, to make sure that we don't end up before where we started.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
weekdayNearestToback to summary
private static TemporalAdjuster weekdayNearestTo(int dayOfMonth)

Returns a temporal adjuster that finds the weekday nearest to the given day-of-month. If dayOfMonth falls on a Saturday, the date is moved back to Friday; if it falls on a Sunday (or if dayOfMonth is 1 and it falls on a Saturday), it is moved forward to Monday.

Parameters
dayOfMonth:int

the goal day-of-month

Returns:TemporalAdjuster

the weekday-nearest-to adjuster