1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2013 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
31
31
* <emphasis>completion</emphasis> time). To measure the interval between the
32
32
* scheduled <emphasis>start</emphasis> time of each execution instead, set the
33
33
* 'fixedRate' property to {@code true}.
34
- * <p>
35
- * Note that the TaskScheduler interface already defines methods for scheduling
34
+ *
35
+ * <p> Note that the TaskScheduler interface already defines methods for scheduling
36
36
* tasks at fixed-rate or with fixed-delay. Both also support an optional value
37
37
* for the initial delay. Those methods should be used directly whenever
38
38
* possible. The value of this Trigger implementation is that it can be used
@@ -68,7 +68,7 @@ public PeriodicTrigger(long period) {
68
68
*/
69
69
public PeriodicTrigger (long period , TimeUnit timeUnit ) {
70
70
Assert .isTrue (period >= 0 , "period must not be negative" );
71
- this .timeUnit = (timeUnit != null ) ? timeUnit : TimeUnit .MILLISECONDS ;
71
+ this .timeUnit = (timeUnit != null ? timeUnit : TimeUnit .MILLISECONDS ) ;
72
72
this .period = this .timeUnit .toMillis (period );
73
73
}
74
74
@@ -91,6 +91,7 @@ public void setFixedRate(boolean fixedRate) {
91
91
this .fixedRate = fixedRate ;
92
92
}
93
93
94
+
94
95
/**
95
96
* Returns the time after which a task should run again.
96
97
*/
@@ -104,6 +105,7 @@ else if (this.fixedRate) {
104
105
return new Date (triggerContext .lastCompletionTime ().getTime () + this .period );
105
106
}
106
107
108
+
107
109
@ Override
108
110
public boolean equals (Object obj ) {
109
111
if (this == obj ) {
@@ -113,16 +115,12 @@ public boolean equals(Object obj) {
113
115
return false ;
114
116
}
115
117
PeriodicTrigger other = (PeriodicTrigger ) obj ;
116
- return this .fixedRate == other .fixedRate
117
- && this .initialDelay == other .initialDelay
118
- && this .period == other .period ;
118
+ return (this .fixedRate == other .fixedRate && this .initialDelay == other .initialDelay && this .period == other .period );
119
119
}
120
120
121
121
@ Override
122
122
public int hashCode () {
123
- return (this .fixedRate ? 17 : 29 ) +
124
- (int ) (37 * this .period ) +
125
- (int ) (41 * this .initialDelay );
123
+ return (this .fixedRate ? 17 : 29 ) + (int ) (37 * this .period ) + (int ) (41 * this .initialDelay );
126
124
}
127
125
128
126
}
0 commit comments