1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.wait;
17
18 import static org.kuali.common.util.base.Precondition.checkMin;
19
20 public final class WaitResult {
21
22 private final long start;
23 private final long stop;
24 private final long elapsed;
25
26 public static WaitResult create(long start, long stop) {
27 return builder(start, stop).build();
28 }
29
30 public static Builder builder(long start, long stop) {
31 return new Builder(start, stop);
32 }
33
34 public static class Builder {
35
36 private final long start;
37 private final long stop;
38 private final long elapsed;
39
40 public Builder(long start, long stop) {
41 this.start = start;
42 this.stop = stop;
43 this.elapsed = stop - start;
44 }
45
46 public WaitResult build() {
47 WaitResult instance = new WaitResult(this);
48 validate(instance);
49 return instance;
50 }
51
52 private static void validate(WaitResult instance) {
53 checkMin(instance.start, 0, "start");
54 checkMin(instance.stop, instance.start, "stop");
55 checkMin(instance.elapsed, 0, "elapsed");
56 }
57
58 }
59
60 private WaitResult(Builder builder) {
61 this.start = builder.start;
62 this.stop = builder.stop;
63 this.elapsed = builder.elapsed;
64 }
65
66 public long getStart() {
67 return start;
68 }
69
70 public long getElapsed() {
71 return elapsed;
72 }
73
74 public long getStop() {
75 return stop;
76 }
77
78 }