1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/*
* SonarQube, open source software quality management tool.
* Copyright (C) 2008-2013 SonarSource
* mailto:contact AT sonarsource DOT com
*
* SonarQube is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* SonarQube is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.wsclient.issue;
import org.sonar.wsclient.unmarshallers.JsonUtils;
import javax.annotation.CheckForNull;
import java.util.*;
/**
* @since 3.6
*/
public class Issue {
private final Map json;
Issue(Map json) {
this.json = json;
}
/**
* Unique key
*/
public String key() {
return JsonUtils.getString(json, "key");
}
public String componentKey() {
return JsonUtils.getString(json, "component");
}
public String projectKey() {
return JsonUtils.getString(json, "project");
}
public String ruleKey() {
return JsonUtils.getString(json, "rule");
}
public String severity() {
return JsonUtils.getString(json, "severity");
}
@CheckForNull
public String message() {
return JsonUtils.getString(json, "message");
}
@CheckForNull
public Integer line() {
return JsonUtils.getInteger(json, "line");
}
@CheckForNull
public Double effortToFix() {
return JsonUtils.getDouble(json, "effortToFix");
}
public String status() {
return JsonUtils.getString(json, "status");
}
/**
* The resolution type. Null if the issue is not resolved.
*/
@CheckForNull
public String resolution() {
return JsonUtils.getString(json, "resolution");
}
@CheckForNull
public String reporter() {
return JsonUtils.getString(json, "reporter");
}
/**
* Login of assignee. Null if issue is not assigned.
*/
@CheckForNull
public String assignee() {
return JsonUtils.getString(json, "assignee");
}
public Date creationDate() {
return JsonUtils.getDateTime(json, "creationDate");
}
public Date updateDate() {
return JsonUtils.getDateTime(json, "updateDate");
}
@CheckForNull
public Date closeDate() {
return JsonUtils.getDateTime(json, "closeDate");
}
@CheckForNull
public String attribute(String key) {
return attributes().get(key);
}
public Map<String, String> attributes() {
Map<String, String> attr = (Map) json.get("attr");
if (attr == null) {
return Collections.emptyMap();
}
return attr;
}
/**
* Non-null list of comments
*/
public List<IssueComment> comments() {
List<IssueComment> comments = new ArrayList();
List<Map> jsonComments = (List<Map>) json.get("comments");
if (jsonComments != null) {
for (Map jsonComment : jsonComments) {
comments.add(new IssueComment(jsonComment));
}
}
return comments;
}
}
|