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;
18
19 import com.atlassian.jira.rest.client.api.ExpandableResource;
20 import com.atlassian.jira.rest.client.api.domain.util.UriUtil;
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 import java.util.Collection;
27 import java.util.Set;
28
29 import static com.atlassian.jira.rest.client.api.IssueRestClient.Expandos;
30
31
32
33
34
35
36 public class Issue extends BasicIssue implements ExpandableResource {
37
38 public Issue(String summary, URI self, String key, Long id, BasicProject project, IssueType issueType, Status status,
39 String description, @Nullable BasicPriority priority, @Nullable Resolution resolution, Collection<Attachment> attachments,
40 @Nullable User reporter, @Nullable User assignee, DateTime creationDate, DateTime updateDate, DateTime dueDate,
41 Collection<Version> affectedVersions, Collection<Version> fixVersions, Collection<BasicComponent> components,
42 @Nullable TimeTracking timeTracking, Collection<IssueField> issueFields, Collection<Comment> comments,
43 @Nullable URI transitionsUri,
44 @Nullable Collection<IssueLink> issueLinks,
45 BasicVotes votes, Collection<Worklog> worklogs, BasicWatchers watchers, Iterable<String> expandos,
46 @Nullable Collection<Subtask> subtasks, @Nullable Collection<ChangelogGroup> changelog, @Nullable Operations operations,
47 Set<String> labels) {
48 super(self, key, id);
49 this.summary = summary;
50 this.project = project;
51 this.status = status;
52 this.description = description;
53 this.resolution = resolution;
54 this.expandos = expandos;
55 this.comments = comments;
56 this.attachments = attachments;
57 this.issueFields = issueFields;
58 this.issueType = issueType;
59 this.reporter = reporter;
60 this.assignee = assignee;
61 this.creationDate = creationDate;
62 this.updateDate = updateDate;
63 this.dueDate = dueDate;
64 this.transitionsUri = transitionsUri;
65 this.issueLinks = issueLinks;
66 this.votes = votes;
67 this.worklogs = worklogs;
68 this.watchers = watchers;
69 this.fixVersions = fixVersions;
70 this.affectedVersions = affectedVersions;
71 this.components = components;
72 this.priority = priority;
73 this.timeTracking = timeTracking;
74 this.subtasks = subtasks;
75 this.changelog = changelog;
76 this.operations = operations;
77 this.labels = labels;
78 }
79
80 private final Status status;
81 private final IssueType issueType;
82 private final BasicProject project;
83 private final URI transitionsUri;
84 private final Iterable<String> expandos;
85 private final Collection<BasicComponent> components;
86 private final String summary;
87 @Nullable
88 private final String description;
89 @Nullable
90 private final User reporter;
91 private final User assignee;
92 @Nullable
93 private final Resolution resolution;
94 private final Collection<IssueField> issueFields;
95 private final DateTime creationDate;
96 private final DateTime updateDate;
97 private final DateTime dueDate;
98 private final BasicPriority priority;
99 private final BasicVotes votes;
100 @Nullable
101 private final Collection<Version> fixVersions;
102 @Nullable
103 private final Collection<Version> affectedVersions;
104
105 private final Collection<Comment> comments;
106
107 @Nullable
108 private final Collection<IssueLink> issueLinks;
109
110 private final Collection<Attachment> attachments;
111
112 private final Collection<Worklog> worklogs;
113 private final BasicWatchers watchers;
114
115 @Nullable
116 private final TimeTracking timeTracking;
117 @Nullable
118 private final Collection<Subtask> subtasks;
119 @Nullable
120 private final Collection<ChangelogGroup> changelog;
121 @Nullable
122 private final Operations operations;
123 private final Set<String> labels;
124
125 public Status getStatus() {
126 return status;
127 }
128
129
130
131
132 @Nullable
133 public User getReporter() {
134 return reporter;
135 }
136
137
138
139
140 @Nullable
141 public User getAssignee() {
142 return assignee;
143 }
144
145
146 public String getSummary() {
147 return summary;
148 }
149
150
151
152
153 @Nullable
154 public BasicPriority getPriority() {
155 return priority;
156 }
157
158
159
160
161 @Nullable
162 public Iterable<IssueLink> getIssueLinks() {
163 return issueLinks;
164 }
165
166 @Nullable
167 public Iterable<Subtask> getSubtasks() {
168 return subtasks;
169 }
170
171
172
173
174 public Iterable<IssueField> getFields() {
175 return issueFields;
176 }
177
178
179
180
181
182 @Nullable
183 public IssueField getField(String id) {
184 for (IssueField issueField : issueFields) {
185 if (issueField.getId().equals(id)) {
186 return issueField;
187 }
188 }
189 return null;
190 }
191
192
193
194
195
196
197
198
199
200 @Nullable
201 public IssueField getFieldByName(String name) {
202 for (IssueField issueField : issueFields) {
203 if (issueField.getName().equals(name)) {
204 return issueField;
205 }
206 }
207 return null;
208 }
209
210 @Override
211 public Iterable<String> getExpandos() {
212 return expandos;
213 }
214
215
216
217
218 public IssueType getIssueType() {
219 return issueType;
220 }
221
222
223
224
225 public Iterable<Attachment> getAttachments() {
226 return attachments;
227 }
228
229 public URI getAttachmentsUri() {
230 return UriUtil.path(getSelf(), "attachments");
231 }
232
233 public URI getWorklogUri() {
234 return UriUtil.path(getSelf(), "worklog");
235 }
236
237
238
239
240 public Iterable<Comment> getComments() {
241 return comments;
242 }
243
244 public URI getCommentsUri() {
245 return UriUtil.path(getSelf(), "comment");
246 }
247
248
249
250
251 public BasicProject getProject() {
252 return project;
253 }
254
255
256
257
258 @Nullable
259 public BasicVotes getVotes() {
260 return votes;
261 }
262
263 public Iterable<Worklog> getWorklogs() {
264 return worklogs;
265 }
266
267
268
269
270 @Nullable
271 public BasicWatchers getWatchers() {
272 return watchers;
273 }
274
275 @Nullable
276 public Iterable<Version> getFixVersions() {
277 return fixVersions;
278 }
279
280 @Nullable
281 public URI getTransitionsUri() {
282 return transitionsUri;
283 }
284
285 @Nullable
286 public Iterable<Version> getAffectedVersions() {
287 return affectedVersions;
288 }
289
290 public Iterable<BasicComponent> getComponents() {
291 return components;
292 }
293
294 public Set<String> getLabels() {
295 return labels;
296 }
297
298
299
300
301
302
303
304
305
306 @Nullable
307 public Iterable<ChangelogGroup> getChangelog() {
308 return changelog;
309 }
310
311
312
313
314
315
316
317
318
319 @Nullable
320 public Operations getOperations() {
321 return operations;
322 }
323
324 public URI getVotesUri() {
325 return UriUtil.path(getSelf(), "votes");
326 }
327
328
329 @Nullable
330 public Resolution getResolution() {
331 return resolution;
332 }
333
334 public DateTime getCreationDate() {
335 return creationDate;
336 }
337
338 public DateTime getUpdateDate() {
339 return updateDate;
340 }
341
342 public DateTime getDueDate() {
343 return dueDate;
344 }
345
346 @Nullable
347 public TimeTracking getTimeTracking() {
348 return timeTracking;
349 }
350
351 @Nullable
352 public String getDescription() {
353 return description;
354 }
355
356 @Override
357 protected Objects.ToStringHelper getToStringHelper() {
358 return super.getToStringHelper().
359 add("project", project).
360 add("status", status).
361 add("description", description).
362 add("expandos", expandos).
363 add("resolution", resolution).
364 add("reporter", reporter).
365 add("assignee", assignee).addValue("\n").
366 add("fields", issueFields).addValue("\n").
367 add("affectedVersions", affectedVersions).addValue("\n").
368 add("fixVersions", fixVersions).addValue("\n").
369 add("components", components).addValue("\n").
370 add("issueType", issueType).
371 add("creationDate", creationDate).
372 add("updateDate", updateDate).addValue("\n").
373 add("dueDate", dueDate).addValue("\n").
374 add("attachments", attachments).addValue("\n").
375 add("comments", comments).addValue("\n").
376 add("transitionsUri", transitionsUri).
377 add("issueLinks", issueLinks).addValue("\n").
378 add("votes", votes).addValue("\n").
379 add("worklogs", worklogs).addValue("\n").
380 add("watchers", watchers).
381 add("timeTracking", timeTracking).
382 add("changelog", changelog).
383 add("operations", operations).
384 add("labels", labels);
385 }
386 }