1 package com.atlassian.scheduler.config;
2
3 import com.atlassian.annotations.PublicApi;
4
5 import javax.annotation.Nullable;
6 import javax.annotation.concurrent.Immutable;
7 import java.util.Date;
8 import java.util.Objects;
9
10 import static com.atlassian.scheduler.util.Safe.copy;
11 import static com.atlassian.util.concurrent.Assertions.isTrue;
12
13
14
15
16
17
18 @Immutable
19 @PublicApi
20 public final class IntervalScheduleInfo {
21 private final Date firstRunTime;
22 private final long intervalInMillis;
23
24 IntervalScheduleInfo(@Nullable final Date firstRunTime, final long intervalInMillis) {
25 this.firstRunTime = copy(firstRunTime);
26 this.intervalInMillis = intervalInMillis;
27
28 isTrue("intervalInMillis must not be negative", intervalInMillis >= 0L);
29 }
30
31
32 @Nullable
33 public Date getFirstRunTime() {
34 return copy(firstRunTime);
35 }
36
37 public long getIntervalInMillis() {
38 return intervalInMillis;
39 }
40
41
42 @Override
43 public boolean equals(@Nullable final Object o) {
44 if (this == o) {
45 return true;
46 }
47 if (o == null || getClass() != o.getClass()) {
48 return false;
49 }
50
51 final IntervalScheduleInfo other = (IntervalScheduleInfo) o;
52 return intervalInMillis == other.intervalInMillis
53 && Objects.equals(firstRunTime, other.firstRunTime);
54 }
55
56 @Override
57 public int hashCode() {
58 return Objects.hash(firstRunTime, intervalInMillis);
59 }
60
61 @Override
62 public String toString() {
63 return "IntervalScheduleInfo[firstRunTime=" + firstRunTime + ",intervalInMillis=" + intervalInMillis + ']';
64 }
65 }