|
5 | 5 | import java.util.Arrays; |
6 | 6 | import java.util.Collections; |
7 | 7 | import java.util.List; |
| 8 | +import java.util.Objects; |
8 | 9 |
|
9 | 10 | /** |
10 | 11 | * Code scanning alert instance for a repository |
@@ -93,41 +94,129 @@ public Location getLocation() { |
93 | 94 | return location; |
94 | 95 | } |
95 | 96 |
|
| 97 | + @Override |
| 98 | + public boolean equals(Object o) { |
| 99 | + if (this == o) |
| 100 | + return true; |
| 101 | + if (o == null || getClass() != o.getClass()) |
| 102 | + return false; |
| 103 | + GHCodeScanningAlertInstance that = (GHCodeScanningAlertInstance) o; |
| 104 | + return Objects.equals(ref, that.ref) && Objects.equals(analysis_key, that.analysis_key) |
| 105 | + && Objects.equals(environment, that.environment) && state == that.state |
| 106 | + && Objects.equals(commit_sha, that.commit_sha) && Arrays.equals(classifications, that.classifications) |
| 107 | + && Objects.equals(message, that.message) && Objects.equals(location, that.location); |
| 108 | + } |
| 109 | + |
| 110 | + @Override |
| 111 | + public int hashCode() { |
| 112 | + int result = Objects.hash(ref, analysis_key, environment, state, commit_sha, message, location); |
| 113 | + result = 31 * result + Arrays.hashCode(classifications); |
| 114 | + return result; |
| 115 | + } |
| 116 | + |
| 117 | + /** |
| 118 | + * Alert message |
| 119 | + */ |
96 | 120 | @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") |
97 | | - static class Message { |
| 121 | + public static class Message { |
98 | 122 | private String text; |
99 | 123 |
|
| 124 | + /** |
| 125 | + * Alert message |
| 126 | + * |
| 127 | + * @return contents of the message |
| 128 | + */ |
100 | 129 | public String getText() { |
101 | 130 | return text; |
102 | 131 | } |
| 132 | + |
| 133 | + @Override |
| 134 | + public boolean equals(Object o) { |
| 135 | + if (this == o) |
| 136 | + return true; |
| 137 | + if (o == null || getClass() != o.getClass()) |
| 138 | + return false; |
| 139 | + Message message = (Message) o; |
| 140 | + return Objects.equals(text, message.text); |
| 141 | + } |
| 142 | + |
| 143 | + @Override |
| 144 | + public int hashCode() { |
| 145 | + return Objects.hash(text); |
| 146 | + } |
103 | 147 | } |
104 | 148 |
|
| 149 | + /** |
| 150 | + * Describe a region within a file for an alert. |
| 151 | + */ |
105 | 152 | @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") |
106 | | - static class Location { |
| 153 | + public static class Location { |
107 | 154 | private String path; |
108 | 155 | private long start_line; |
109 | 156 | private long end_line; |
110 | 157 | private long start_column; |
111 | 158 | private long end_column; |
112 | 159 |
|
| 160 | + /** |
| 161 | + * Path to the file containing the described code region |
| 162 | + * |
| 163 | + * @return path |
| 164 | + */ |
113 | 165 | public String getPath() { |
114 | 166 | return path; |
115 | 167 | } |
116 | 168 |
|
| 169 | + /** |
| 170 | + * Line number at the start of the code region. |
| 171 | + * |
| 172 | + * @return line number at the start of the code region |
| 173 | + */ |
117 | 174 | public long getStartLine() { |
118 | 175 | return start_line; |
119 | 176 | } |
120 | 177 |
|
| 178 | + /** |
| 179 | + * Line number at the end of the code region. |
| 180 | + * |
| 181 | + * @return line number at the end of the code region |
| 182 | + */ |
121 | 183 | public long getEndLine() { |
122 | 184 | return end_line; |
123 | 185 | } |
124 | 186 |
|
| 187 | + /** |
| 188 | + * Column number at the start of the code region. |
| 189 | + * |
| 190 | + * @return column number at the start of the code region |
| 191 | + */ |
125 | 192 | public long getStartColumn() { |
126 | 193 | return start_column; |
127 | 194 | } |
128 | 195 |
|
| 196 | + /** |
| 197 | + * Column number at the end of the code region. |
| 198 | + * |
| 199 | + * @return column number at the end of the code region |
| 200 | + */ |
129 | 201 | public long getEndColumn() { |
130 | 202 | return end_column; |
131 | 203 | } |
| 204 | + |
| 205 | + @Override |
| 206 | + public boolean equals(Object o) { |
| 207 | + if (this == o) |
| 208 | + return true; |
| 209 | + if (o == null || getClass() != o.getClass()) |
| 210 | + return false; |
| 211 | + Location location = (Location) o; |
| 212 | + return start_line == location.start_line && end_line == location.end_line |
| 213 | + && start_column == location.start_column && end_column == location.end_column |
| 214 | + && path.equals(location.path); |
| 215 | + } |
| 216 | + |
| 217 | + @Override |
| 218 | + public int hashCode() { |
| 219 | + return Objects.hash(path, start_line, end_line, start_column, end_column); |
| 220 | + } |
132 | 221 | } |
133 | 222 | } |
0 commit comments