-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBasePollingOptions.java
More file actions
52 lines (46 loc) · 1.41 KB
/
BasePollingOptions.java
File metadata and controls
52 lines (46 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.mindee.clientOptions;
import lombok.Getter;
/**
* Options to pass for asynchronous parsing with polling.
*/
public abstract class BasePollingOptions {
/**
* Wait this many seconds before the first polling attempt.
*/
@Getter
Double initialDelaySec;
/**
* Wait this many seconds between each polling attempt.
*/
@Getter
Double intervalSec;
/**
* Maximum number of times to poll.
*/
@Getter
Integer maxRetries;
protected BasePollingOptions(
Double initialDelaySec,
Double intervalSec,
Integer maxRetries,
double defaultInitialDelaySec,
double defaultIntervalSec,
int defaultMaxRetries,
double minInitialDelaySec,
double minIntervalSec,
int minMaxRetries
) {
this.initialDelaySec = initialDelaySec == null ? defaultInitialDelaySec : initialDelaySec;
this.intervalSec = intervalSec == null ? defaultIntervalSec : intervalSec;
this.maxRetries = maxRetries == null ? defaultMaxRetries : maxRetries;
if (this.initialDelaySec < minInitialDelaySec) {
throw new IllegalArgumentException("Initial delay must be ≥ " + minInitialDelaySec);
}
if (this.intervalSec < minIntervalSec) {
throw new IllegalArgumentException("Interval must be ≥ " + minIntervalSec);
}
if (this.maxRetries < minMaxRetries) {
throw new IllegalArgumentException("Max retries must be ≥ " + minMaxRetries);
}
}
}