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 package com.jcabi.github;
31
32 import com.jcabi.aspects.Immutable;
33 import com.jcabi.aspects.Loggable;
34 import java.io.IOException;
35 import javax.json.JsonObject;
36 import javax.json.JsonValue;
37 import lombok.EqualsAndHashCode;
38 import lombok.ToString;
39
40
41
42
43
44
45
46
47 @Immutable
48 @SuppressWarnings({"PMD.TooManyMethods", "PMD.ExcessivePublicCount"})
49 public interface Repo extends JsonReadable, JsonPatchable, Comparable<Repo> {
50
51
52
53
54
55 Github github();
56
57
58
59
60
61 Coordinates coordinates();
62
63
64
65
66
67 Issues issues();
68
69
70
71
72
73
74 Milestones milestones();
75
76
77
78
79
80 Pulls pulls();
81
82
83
84
85
86
87 Hooks hooks();
88
89
90
91
92
93
94 IssueEvents issueEvents();
95
96
97
98
99
100
101 Labels labels();
102
103
104
105
106
107
108 Assignees assignees();
109
110
111
112
113
114
115 Releases releases();
116
117
118
119
120
121
122 DeployKeys keys();
123
124
125
126
127
128
129 Forks forks();
130
131
132
133
134
135
136 RepoCommits commits();
137
138
139
140
141
142
143 Branches branches();
144
145
146
147
148
149
150 Contents contents();
151
152
153
154
155
156
157 Collaborators collaborators();
158
159
160
161
162
163
164 Git git();
165
166
167
168
169
170
171
172 Stars stars();
173
174
175
176
177
178
179
180 Notifications notifications();
181
182
183
184
185
186
187
188
189 Iterable<Language> languages() throws IOException;
190
191
192
193
194
195
196
197 Branch defaultBranch() throws IOException;
198
199
200
201
202
203 Stargazers stargazers();
204
205
206
207
208 @Immutable
209 @ToString
210 @Loggable(Loggable.DEBUG)
211 @EqualsAndHashCode(of = {"repo", "jsn"})
212 final class Smart implements Repo {
213
214
215
216 private final transient Repo repo;
217
218
219
220 private final transient SmartJson jsn;
221
222
223
224
225
226 public Smart(
227 final Repo rep
228 ) {
229 this.repo = rep;
230 this.jsn = new SmartJson(rep);
231 }
232
233
234
235
236
237
238 public boolean exists() throws IOException {
239 return new Existence(this.repo).check();
240 }
241
242
243
244
245
246
247 public boolean hasDescription() throws IOException {
248 return this.jsn.hasNotNull("description");
249 }
250
251
252
253
254
255
256 public String description() throws IOException {
257 return this.jsn.text("description");
258 }
259
260
261
262
263
264
265 public boolean isPrivate() throws IOException {
266 return Boolean.parseBoolean(
267 this.json()
268 .getOrDefault("private", JsonValue.FALSE)
269 .toString().replace("\"", "")
270 );
271 }
272
273 @Override
274 public Github github() {
275 return this.repo.github();
276 }
277
278 @Override
279 public Coordinates coordinates() {
280 return this.repo.coordinates();
281 }
282
283 @Override
284 public Issues issues() {
285 return this.repo.issues();
286 }
287
288 @Override
289 public Milestones milestones() {
290 return this.repo.milestones();
291 }
292
293 @Override
294 public Pulls pulls() {
295 return this.repo.pulls();
296 }
297
298 @Override
299 public Hooks hooks() {
300 return this.repo.hooks();
301 }
302
303 @Override
304 public IssueEvents issueEvents() {
305 return this.repo.issueEvents();
306 }
307
308 @Override
309 public Labels labels() {
310 return this.repo.labels();
311 }
312
313 @Override
314 public Assignees assignees() {
315 return this.repo.assignees();
316 }
317
318 @Override
319 public Releases releases() {
320 return this.repo.releases();
321 }
322
323 @Override
324 public DeployKeys keys() {
325 return this.repo.keys();
326 }
327
328 @Override
329 public Forks forks() {
330 return this.repo.forks();
331 }
332
333 @Override
334 public Contents contents() {
335 return this.repo.contents();
336 }
337
338 @Override
339 public Collaborators collaborators() {
340 return this.repo.collaborators();
341 }
342
343 @Override
344 public Git git() {
345 return this.repo.git();
346 }
347
348 @Override
349 public Stars stars() {
350 return this.repo.stars();
351 }
352
353 @Override
354 public Notifications notifications() {
355 return this.repo.notifications();
356 }
357
358 @Override
359 public Iterable<Language> languages() throws IOException {
360 return this.repo.languages();
361 }
362
363 @Override
364 public Branch defaultBranch() throws IOException {
365 return this.repo.defaultBranch();
366 }
367
368 @Override
369 public Stargazers stargazers() {
370 throw new UnsupportedOperationException(
371 "stargazers() not yet implemented"
372 );
373 }
374
375 @Override
376 public void patch(
377 final JsonObject json
378 ) throws IOException {
379 this.repo.patch(json);
380 }
381
382 @Override
383 public RepoCommits commits() {
384 return this.repo.commits();
385 }
386
387 @Override
388 public Branches branches() {
389 return this.repo.branches();
390 }
391
392 @Override
393 public JsonObject json() throws IOException {
394 return this.repo.json();
395 }
396
397 @Override
398 public int compareTo(final Repo repos) {
399 return this.repo.compareTo(repos);
400 }
401 }
402
403 }