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