@@ -36,6 +36,7 @@ private WaitStrategies() {
36
36
37
37
/**
38
38
* Returns a strategy that doesn't sleep at all before retrying.
39
+ * @return A wait strategy which doesn't wait between retries
39
40
*/
40
41
public static WaitStrategy noWait () {
41
42
return NO_WAIT_STRATEGY ;
@@ -46,6 +47,7 @@ public static WaitStrategy noWait() {
46
47
*
47
48
* @param sleepTime the time to sleep
48
49
* @param timeUnit the unit of the time to sleep
50
+ * @return A wait strategy with fixed {@code sleepTime}
49
51
* @throws IllegalStateException if the sleep time is < 0.
50
52
*/
51
53
public static WaitStrategy fixedWait (long sleepTime , @ Nonnull TimeUnit timeUnit ) throws IllegalStateException {
@@ -58,6 +60,7 @@ public static WaitStrategy fixedWait(long sleepTime, @Nonnull TimeUnit timeUnit)
58
60
*
59
61
* @param maximumTime the maximum time to sleep
60
62
* @param timeUnit the unit of the maximum time
63
+ * @return A wait strategy with random wait time
61
64
* @throws IllegalStateException if the maximum sleep time is <= 0.
62
65
*/
63
66
public static WaitStrategy randomWait (long maximumTime , @ Nonnull TimeUnit timeUnit ) {
@@ -72,6 +75,7 @@ public static WaitStrategy randomWait(long maximumTime, @Nonnull TimeUnit timeUn
72
75
* @param minimumTimeUnit the unit of the minimum time
73
76
* @param maximumTime the maximum time to sleep
74
77
* @param maximumTimeUnit the unit of the maximum time
78
+ * @return A wait strategy with random wait time
75
79
* @throws IllegalStateException if the minimum sleep time is < 0, or if the
76
80
* maximum sleep time is less than (or equals to) the minimum.
77
81
*/
@@ -94,6 +98,7 @@ public static WaitStrategy randomWait(long minimumTime,
94
98
* @param initialSleepTimeUnit the unit of the initial sleep time
95
99
* @param increment the increment added to the previous sleep time after each failed attempt
96
100
* @param incrementTimeUnit the unit of the increment
101
+ * @return A wait strategy with wait time following the incremental pattern.
97
102
*/
98
103
public static WaitStrategy incrementingWait (long initialSleepTime ,
99
104
@ Nonnull TimeUnit initialSleepTimeUnit ,
@@ -108,6 +113,8 @@ public static WaitStrategy incrementingWait(long initialSleepTime,
108
113
/**
109
114
* Returns a strategy which sleeps for an exponential amount of time after the first failed attempt,
110
115
* and in exponentially incrementing amounts after each failed attempt up to Long.MAX_VALUE.
116
+ *
117
+ * @return A wait strategy with wait time following the exponential pattern.
111
118
*/
112
119
public static WaitStrategy exponentialWait () {
113
120
return new ExponentialWaitStrategy (1 , Long .MAX_VALUE );
@@ -119,6 +126,7 @@ public static WaitStrategy exponentialWait() {
119
126
*
120
127
* @param maximumTime the maximum time to sleep
121
128
* @param maximumTimeUnit the unit of the maximum time
129
+ * @return A wait strategy with wait time following the exponential pattern.
122
130
*/
123
131
public static WaitStrategy exponentialWait (long maximumTime ,
124
132
@ Nonnull TimeUnit maximumTimeUnit ) {
@@ -129,10 +137,13 @@ public static WaitStrategy exponentialWait(long maximumTime,
129
137
/**
130
138
* Returns a strategy which sleeps for an exponential amount of time after the first failed attempt,
131
139
* and in exponentially incrementing amounts after each failed attempt up to the maximumTime.
140
+ * The wait time between the retries can be controlled by the multiplier.
141
+ * nextWaitTime = exponentialIncrement * {@code multiplier}.
132
142
*
133
143
* @param multiplier multiply the wait time calculated by this
134
144
* @param maximumTime the maximum time to sleep
135
145
* @param maximumTimeUnit the unit of the maximum time
146
+ * @return A wait strategy with wait time following the exponential pattern.
136
147
*/
137
148
public static WaitStrategy exponentialWait (long multiplier ,
138
149
long maximumTime ,
@@ -144,6 +155,8 @@ public static WaitStrategy exponentialWait(long multiplier,
144
155
/**
145
156
* Returns a strategy which sleeps for an increasing amount of time after the first failed attempt,
146
157
* and in Fibonacci increments after each failed attempt up to {@link Long#MAX_VALUE}.
158
+ *
159
+ * @return A wait strategy with wait time following the fibonacci pattern.
147
160
*/
148
161
public static WaitStrategy fibonacciWait () {
149
162
return new FibonacciWaitStrategy (1 , Long .MAX_VALUE );
@@ -155,6 +168,7 @@ public static WaitStrategy fibonacciWait() {
155
168
*
156
169
* @param maximumTime the maximum time to sleep
157
170
* @param maximumTimeUnit the unit of the maximum time
171
+ * @return A wait strategy with wait time following the fibonacci pattern.
158
172
*/
159
173
public static WaitStrategy fibonacciWait (long maximumTime ,
160
174
@ Nonnull TimeUnit maximumTimeUnit ) {
@@ -165,10 +179,13 @@ public static WaitStrategy fibonacciWait(long maximumTime,
165
179
/**
166
180
* Returns a strategy which sleeps for an increasing amount of time after the first failed attempt,
167
181
* and in Fibonacci increments after each failed attempt up to the {@code maximumTime}.
182
+ * The wait time between the retries can be controlled by the multiplier.
183
+ * nextWaitTime = fibonacciIncrement * {@code multiplier}.
168
184
*
169
185
* @param multiplier multiply the wait time calculated by this
170
186
* @param maximumTime the maximum time to sleep
171
187
* @param maximumTimeUnit the unit of the maximum time
188
+ * @return A wait strategy with wait time following the fibonacci pattern.
172
189
*/
173
190
public static WaitStrategy fibonacciWait (long multiplier ,
174
191
long maximumTime ,
0 commit comments