Skip to content

Commit 85baba3

Browse files
committed
Accessors for PeriodicTrigger properties
Issue: SPR-15982
1 parent fb7b7d0 commit 85baba3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

spring-context/src/main/java/org/springframework/scheduling/support/PeriodicTrigger.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ public PeriodicTrigger(long period, @Nullable TimeUnit timeUnit) {
7474
}
7575

7676

77+
/**
78+
* Return this trigger's period.
79+
* @since 5.0.2
80+
*/
81+
public long getPeriod() {
82+
return this.period;
83+
}
84+
85+
/**
86+
* Return this trigger's time unit (milliseconds by default).
87+
* @since 5.0.2
88+
*/
89+
public TimeUnit getTimeUnit() {
90+
return this.timeUnit;
91+
}
92+
7793
/**
7894
* Specify the delay for the initial execution. It will be evaluated in
7995
* terms of this trigger's {@link TimeUnit}. If no time unit was explicitly
@@ -83,6 +99,14 @@ public void setInitialDelay(long initialDelay) {
8399
this.initialDelay = this.timeUnit.toMillis(initialDelay);
84100
}
85101

102+
/**
103+
* Return the initial delay, or 0 if none.
104+
* @since 5.0.2
105+
*/
106+
public long getInitialDelay() {
107+
return this.initialDelay;
108+
}
109+
86110
/**
87111
* Specify whether the periodic interval should be measured between the
88112
* scheduled start times rather than between actual completion times.
@@ -92,6 +116,15 @@ public void setFixedRate(boolean fixedRate) {
92116
this.fixedRate = fixedRate;
93117
}
94118

119+
/**
120+
* Return whether this trigger uses fixed rate ({@code true}) or
121+
* fixed delay ({@code false}) behavior.
122+
* @since 5.0.2
123+
*/
124+
public boolean isFixedRate() {
125+
return this.fixedRate;
126+
}
127+
95128

96129
/**
97130
* Returns the time after which a task should run again.

0 commit comments

Comments
 (0)