001package org.kuali.common.util.wait;
002
003import org.kuali.common.util.Assert;
004
005public final class WaitResult {
006
007        private final long start;
008        private final long stop;
009        private final long elapsed;
010
011        public static class Builder {
012
013                private final long start;
014                private final long stop;
015                private final long elapsed;
016
017                public Builder(long start, long stop) {
018                        this.start = start;
019                        this.stop = stop;
020                        this.elapsed = stop - start;
021                }
022
023                public WaitResult build() {
024                        Assert.noNegatives(start, stop, elapsed);
025                        Assert.isTrue(stop >= start, "stop is less than start");
026                        return new WaitResult(this);
027                }
028
029        }
030
031        private WaitResult(Builder builder) {
032                this.start = builder.start;
033                this.stop = builder.stop;
034                this.elapsed = builder.elapsed;
035        }
036
037        public long getStart() {
038                return start;
039        }
040
041        public long getElapsed() {
042                return elapsed;
043        }
044
045        public long getStop() {
046                return stop;
047        }
048
049}