1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.jira.rest.client.domain.input;
18
19 import com.atlassian.jira.rest.client.domain.BasicUser;
20 import com.atlassian.jira.rest.client.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 public WorklogInput(@Nullable URI self, URI issueUri, @Nullable BasicUser author, @Nullable BasicUser updateAuthor,
71 @Nullable String comment, DateTime startDate, int minutesSpent, @Nullable Visibility visibility,
72 AdjustEstimate adjustEstimate, @Nullable String adjustEstimateValue) {
73 this.visibility = visibility;
74 this.minutesSpent = minutesSpent;
75 this.startDate = startDate;
76 this.comment = comment;
77 this.updateAuthor = updateAuthor;
78 this.author = author;
79 this.issueUri = issueUri;
80 this.self = self;
81 this.adjustEstimate = adjustEstimate;
82 this.adjustEstimateValue = adjustEstimateValue;
83 }
84
85
86
87
88
89
90
91
92
93
94
95
96 public WorklogInput(@Nullable URI self, URI issueUri, @Nullable BasicUser author, @Nullable BasicUser updateAuthor,
97 @Nullable String comment, DateTime startDate, int minutesSpent, @Nullable Visibility visibility) {
98 this(self, issueUri, author, updateAuthor, comment, startDate, minutesSpent, visibility, AdjustEstimate.AUTO, null);
99 }
100
101 public static WorklogInput create(URI issueUri, @Nullable String comment, DateTime startDate, int minutesSpent) {
102 return new WorklogInputBuilder(issueUri).setComment(comment).setStartDate(startDate).setMinutesSpent(minutesSpent).build();
103 }
104
105 public static WorklogInput create(URI issueUri, @Nullable String comment, DateTime startDate, int minutesSpent, @Nullable Visibility visibility) {
106 return new WorklogInputBuilder(issueUri).setComment(comment).setStartDate(startDate).setMinutesSpent(minutesSpent)
107 .setVisibility(visibility).build();
108 }
109
110 @Nullable
111 public URI getSelf() {
112 return self;
113 }
114
115 public URI getIssueUri() {
116 return issueUri;
117 }
118
119 @Nullable
120 public BasicUser getAuthor() {
121 return author;
122 }
123
124 @Nullable
125 public BasicUser getUpdateAuthor() {
126 return updateAuthor;
127 }
128
129 @Nullable
130 public String getComment() {
131 return comment;
132 }
133
134 public DateTime getStartDate() {
135 return startDate;
136 }
137
138 public int getMinutesSpent() {
139 return minutesSpent;
140 }
141
142 @Nullable
143 public Visibility getVisibility() {
144 return visibility;
145 }
146
147 public AdjustEstimate getAdjustEstimate() {
148 return adjustEstimate;
149 }
150
151 @Nullable
152 public String getAdjustEstimateValue() {
153 return adjustEstimateValue;
154 }
155
156 @Override
157 public String toString() {
158 return Objects.toStringHelper(this)
159 .add("self", self)
160 .add("issueUri", issueUri)
161 .add("author", author)
162 .add("updateAuthor", updateAuthor)
163 .add("comment", comment)
164 .add("startDate", startDate)
165 .add("minutesSpent", minutesSpent)
166 .add("visibility", visibility)
167 .add("adjustEstimate", adjustEstimate)
168 .add("adjustEstimateValue", adjustEstimateValue)
169 .toString();
170 }
171
172 @Override
173 public boolean equals(Object obj) {
174 if (obj instanceof WorklogInput) {
175 final WorklogInput that = (WorklogInput) obj;
176
177 return Objects.equal(this.self, that.self)
178 && Objects.equal(this.issueUri, that.issueUri)
179 && Objects.equal(this.author, that.author)
180 && Objects.equal(this.updateAuthor, that.updateAuthor)
181 && Objects.equal(this.comment, that.comment)
182 && Objects.equal(this.startDate, that.startDate)
183 && Objects.equal(this.minutesSpent, that.minutesSpent)
184 && Objects.equal(this.visibility, that.visibility)
185 && Objects.equal(this.adjustEstimate, that.adjustEstimate)
186 && Objects.equal(this.adjustEstimateValue, that.adjustEstimateValue);
187 }
188 return false;
189 }
190
191 @Override
192 public int hashCode() {
193 return Objects.hashCode(self, issueUri, author, updateAuthor, comment, startDate, minutesSpent, visibility,
194 adjustEstimate, adjustEstimateValue);
195 }
196
197 public static enum AdjustEstimate {
198
199
200
201 NEW,
202
203
204
205 LEAVE,
206
207
208
209 MANUAL,
210
211
212
213 AUTO;
214
215 public final String restValue;
216
217 private AdjustEstimate() {
218 restValue = this.name().toLowerCase();
219 }
220 }
221 }
222