1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.linecorp.centraldogma.client;
17
18 import static com.google.common.base.Preconditions.checkArgument;
19 import static java.util.Objects.requireNonNull;
20
21 import java.time.Duration;
22
23 import com.linecorp.centraldogma.common.EntryNotFoundException;
24
25
26
27
28 abstract class WatchOptions {
29
30 private long timeoutMillis = WatchConstants.DEFAULT_WATCH_TIMEOUT_MILLIS;
31 private boolean errorOnEntryNotFound = WatchConstants.DEFAULT_WATCH_ERROR_ON_ENTRY_NOT_FOUND;
32
33
34
35
36 WatchOptions timeout(Duration timeout) {
37 requireNonNull(timeout, "timeout");
38 checkArgument(!timeout.isZero() && !timeout.isNegative(), "timeout: %s (expected: > 0)", timeout);
39 return timeoutMillis(timeout.toMillis());
40 }
41
42
43
44
45 WatchOptions timeoutMillis(long timeoutMillis) {
46 checkArgument(timeoutMillis > 0, "timeoutMillis: %s (expected: > 0)", timeoutMillis);
47 this.timeoutMillis = timeoutMillis;
48 return this;
49 }
50
51 long timeoutMillis() {
52 return timeoutMillis;
53 }
54
55
56
57
58 public WatchOptions errorOnEntryNotFound(boolean errorOnEntryNotFound) {
59 this.errorOnEntryNotFound = errorOnEntryNotFound;
60 return this;
61 }
62
63 boolean errorOnEntryNotFound() {
64 return errorOnEntryNotFound;
65 }
66 }