1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.jira.rest.client.api.domain.input;
18
19 import com.atlassian.jira.rest.client.api.domain.BasicUser;
20 import com.atlassian.jira.rest.client.api.domain.Visibility;
21 import com.google.common.base.Objects;
22 import org.joda.time.DateTime;
23
24 import javax.annotation.Nullable;
25 import java.net.URI;
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 public class WorklogInput {
41 @Nullable
42 private final URI self;
43 private final URI issueUri;
44 @Nullable
45 private final BasicUser author;
46 @Nullable
47 private final BasicUser updateAuthor;
48 @Nullable
49 private final String comment;
50 private final DateTime startDate;
51 private final int minutesSpent;
52 @Nullable
53 private final Visibility visibility;
54
55 @Nullable
56 private final String adjustEstimateValue;
57 private final AdjustEstimate adjustEstimate;
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 public WorklogInput(@Nullable URI self, URI issueUri, @Nullable BasicUser author, @Nullable BasicUser updateAuthor,
75 @Nullable String comment, DateTime startDate, int minutesSpent, @Nullable Visibility visibility,
76 AdjustEstimate adjustEstimate, @Nullable String adjustEstimateValue) {
77 this.visibility = visibility;
78 this.minutesSpent = minutesSpent;
79 this.startDate = startDate;
80 this.comment = comment;
81 this.updateAuthor = updateAuthor;
82 this.author = author;
83 this.issueUri = issueUri;
84 this.self = self;
85 this.adjustEstimate = adjustEstimate;
86 this.adjustEstimateValue = adjustEstimateValue;
87 }
88
89
90
91
92
93
94
95
96
97
98
99
100
101 public WorklogInput(@Nullable URI self, URI issueUri, @Nullable BasicUser author, @Nullable BasicUser updateAuthor,
102 @Nullable String comment, DateTime startDate, int minutesSpent, @Nullable Visibility visibility) {
103 this(self, issueUri, author, updateAuthor, comment, startDate, minutesSpent, visibility, AdjustEstimate.AUTO, null);
104 }
105
106 public static WorklogInput create(URI issueUri, @Nullable String comment, DateTime startDate, int minutesSpent) {
107 return new WorklogInputBuilder(issueUri).setComment(comment).setStartDate(startDate).setMinutesSpent(minutesSpent)
108 .build();
109 }
110
111 public static WorklogInput create(URI issueUri, @Nullable String comment, DateTime startDate, int minutesSpent, @Nullable Visibility visibility) {
112 return new WorklogInputBuilder(issueUri).setComment(comment).setStartDate(startDate).setMinutesSpent(minutesSpent)
113 .setVisibility(visibility).build();
114 }
115
116 @Nullable
117 public URI getSelf() {
118 return self;
119 }
120
121 public URI getIssueUri() {
122 return issueUri;
123 }
124
125 @Nullable
126 public BasicUser getAuthor() {
127 return author;
128 }
129
130 @Nullable
131 public BasicUser getUpdateAuthor() {
132 return updateAuthor;
133 }
134
135 @Nullable
136 public String getComment() {
137 return comment;
138 }
139
140 public DateTime getStartDate() {
141 return startDate;
142 }
143
144 public int getMinutesSpent() {
145 return minutesSpent;
146 }
147
148 @Nullable
149 public Visibility getVisibility() {
150 return visibility;
151 }
152
153 public AdjustEstimate getAdjustEstimate() {
154 return adjustEstimate;
155 }
156
157 @Nullable
158 public String getAdjustEstimateValue() {
159 return adjustEstimateValue;
160 }
161
162 @Override
163 public String toString() {
164 return Objects.toStringHelper(this)
165 .add("self", self)
166 .add("issueUri", issueUri)
167 .add("author", author)
168 .add("updateAuthor", updateAuthor)
169 .add("comment", comment)
170 .add("startDate", startDate)
171 .add("minutesSpent", minutesSpent)
172 .add("visibility", visibility)
173 .add("adjustEstimate", adjustEstimate)
174 .add("adjustEstimateValue", adjustEstimateValue)
175 .toString();
176 }
177
178 @Override
179 public boolean equals(Object obj) {
180 if (obj instanceof WorklogInput) {
181 final WorklogInput that = (WorklogInput) obj;
182
183 return Objects.equal(this.self, that.self)
184 && Objects.equal(this.issueUri, that.issueUri)
185 && Objects.equal(this.author, that.author)
186 && Objects.equal(this.updateAuthor, that.updateAuthor)
187 && Objects.equal(this.comment, that.comment)
188 && Objects.equal(this.startDate, that.startDate)
189 && Objects.equal(this.minutesSpent, that.minutesSpent)
190 && Objects.equal(this.visibility, that.visibility)
191 && Objects.equal(this.adjustEstimate, that.adjustEstimate)
192 && Objects.equal(this.adjustEstimateValue, that.adjustEstimateValue);
193 }
194 return false;
195 }
196
197 @Override
198 public int hashCode() {
199 return Objects.hashCode(self, issueUri, author, updateAuthor, comment, startDate, minutesSpent, visibility,
200 adjustEstimate, adjustEstimateValue);
201 }
202
203 public static enum AdjustEstimate {
204
205
206
207 NEW,
208
209
210
211 LEAVE,
212
213
214
215 MANUAL,
216
217
218
219 AUTO;
220
221 public final String restValue;
222
223 private AdjustEstimate() {
224 restValue = this.name().toLowerCase();
225 }
226 }
227 }
228