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