Skip to content

Commit 9dd5d2e

Browse files
committed
Merge branch '__rultor'
2 parents f862661 + 647b98b commit 9dd5d2e

File tree

9 files changed

+600
-181
lines changed

9 files changed

+600
-181
lines changed

src/main/java/com/jcabi/github/Check.java

Lines changed: 185 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
*/
3030
package com.jcabi.github;
3131

32+
import java.io.IOException;
33+
import java.util.Arrays;
34+
import java.util.Locale;
35+
3236
/**
3337
* Github check.
3438
*
@@ -42,7 +46,187 @@ public interface Check {
4246
/**
4347
* Checks whether Check was successful.
4448
* @return True if Check was successful.
49+
* @throws IOException If there is any I/O problem.
50+
*/
51+
boolean successful() throws IOException;
52+
53+
/**
54+
* Check status.
55+
* You can read more about it
56+
* @checkstyle LineLengthCheck (1 lines)
57+
* <a href="https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#list-check-runs-for-a-git-reference"> here </a>
58+
*/
59+
enum Status {
60+
/**
61+
* Queued.
62+
*/
63+
QUEUED("queued"),
64+
65+
/**
66+
* In progress.
67+
*/
68+
IN_PROGRESS("in_progress"),
69+
70+
/**
71+
* Completed.
72+
*/
73+
COMPLETED("completed");
74+
75+
/**
76+
* Status.
77+
*/
78+
private final String status;
79+
80+
/**
81+
* Ctor.
82+
* @param stat Status.
83+
*/
84+
Status(final String stat) {
85+
this.status = stat;
86+
}
87+
88+
/**
89+
* Status.
90+
* @return Status.
91+
*/
92+
public String value() {
93+
return this.status;
94+
}
95+
96+
/**
97+
* Get status from string.
98+
* @param value String value.
99+
* @return Status.
100+
*/
101+
public static Status fromString(final String value) {
102+
return Arrays.stream(Status.values())
103+
.filter(stat -> stat.same(value))
104+
.findFirst()
105+
.orElseThrow(
106+
() -> new IllegalArgumentException(
107+
String.format("Invalid value %s for status", value)
108+
)
109+
);
110+
}
111+
112+
/**
113+
* Check if check is finished.
114+
* @return True if check is finished.
115+
*/
116+
boolean finished() {
117+
return this == Status.COMPLETED;
118+
}
119+
120+
/**
121+
* Check if status is the same as value.
122+
* @param value Value.
123+
* @return True if status is the same as value.
124+
*/
125+
boolean same(final String value) {
126+
return this.status.equals(value.toLowerCase(Locale.ROOT));
127+
}
128+
}
129+
130+
/**
131+
* Check conclusion.
132+
* You can read more about it
133+
* @checkstyle LineLengthCheck (1 lines)
134+
* <a href="https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#list-check-runs-for-a-git-reference"> here </a>
45135
*/
46-
boolean successful();
136+
enum Conclusion {
137+
138+
/**
139+
* Action required.
140+
*/
141+
ACTION_REQUIRED("action_required"),
142+
143+
/**
144+
* Cancelled.
145+
*/
146+
CANCELLED("cancelled"),
147+
148+
/**
149+
* Failure.
150+
*/
151+
FAILURE("failure"),
152+
153+
/**
154+
* Neutral.
155+
*/
156+
NEUTRAL("neutral"),
157+
158+
/**
159+
* Success.
160+
*/
161+
SUCCESS("success"),
162+
163+
/**
164+
* Skipped.
165+
*/
166+
SKIPPED("skipped"),
167+
168+
/**
169+
* Stale.
170+
*/
171+
STALE("stale"),
172+
173+
/**
174+
* Timed out.
175+
*/
176+
TIMED_OUT("timed_out");
177+
178+
/**
179+
* Conclusion.
180+
*/
181+
private final String conclusion;
182+
183+
/**
184+
* Ctor.
185+
* @param con Conclusion.
186+
*/
187+
Conclusion(final String con) {
188+
this.conclusion = con;
189+
}
190+
191+
/**
192+
* Get conclusion from string.
193+
* @param value String value.
194+
* @return Conclusion.
195+
*/
196+
public static Conclusion fromString(final String value) {
197+
return Arrays.stream(Conclusion.values())
198+
.filter(stat -> stat.same(value))
199+
.findFirst()
200+
.orElseThrow(
201+
() -> new IllegalArgumentException(
202+
String.format("Invalid value %s for conclusion", value)
203+
)
204+
);
205+
}
206+
207+
/**
208+
* Conclusion.
209+
* @return Conclusion.
210+
*/
211+
public String value() {
212+
return this.conclusion;
213+
}
214+
215+
/**
216+
* Check if check is successful.
217+
* @return True if check is successful.
218+
*/
219+
boolean successful() {
220+
return this == Conclusion.SUCCESS;
221+
}
47222

223+
/**
224+
* Check if conclusion is the same as value.
225+
* @param value Value to compare.
226+
* @return True if conclusion is the same as value.
227+
*/
228+
boolean same(final String value) {
229+
return this.conclusion.equals(value.toLowerCase(Locale.ROOT));
230+
}
231+
}
48232
}

src/main/java/com/jcabi/github/RtCheck.java

Lines changed: 1 addition & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
*/
3030
package com.jcabi.github;
3131

32-
import java.util.Arrays;
33-
import java.util.Locale;
34-
3532
/**
3633
* Github check.
3734
*
@@ -57,10 +54,7 @@ class RtCheck implements Check {
5754
* @param stat Status.
5855
* @param conc Conclusion.
5956
*/
60-
RtCheck(
61-
final String stat,
62-
final String conc
63-
) {
57+
RtCheck(final String stat, final String conc) {
6458
this(Status.fromString(stat), Conclusion.fromString(conc));
6559
}
6660

@@ -81,168 +75,4 @@ class RtCheck implements Check {
8175
public boolean successful() {
8276
return this.status.finished() && this.conclusion.successful();
8377
}
84-
85-
/**
86-
* Check status.
87-
* You can read more about it
88-
* @checkstyle LineLengthCheck (1 lines)
89-
* <a href="https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#list-check-runs-for-a-git-reference"> here </a>
90-
*/
91-
enum Status {
92-
/**
93-
* Queued.
94-
*/
95-
QUEUED("queued"),
96-
97-
/**
98-
* In progress.
99-
*/
100-
IN_PROGRESS("in_progress"),
101-
102-
/**
103-
* Completed.
104-
*/
105-
COMPLETED("completed");
106-
107-
/**
108-
* Status.
109-
*/
110-
private final String status;
111-
112-
/**
113-
* Ctor.
114-
* @param stat Status.
115-
*/
116-
Status(final String stat) {
117-
this.status = stat;
118-
}
119-
120-
/**
121-
* Check if check is finished.
122-
* @return True if check is finished.
123-
*/
124-
boolean finished() {
125-
return this == Status.COMPLETED;
126-
}
127-
128-
/**
129-
* Get status from string.
130-
* @param value String value.
131-
* @return Status.
132-
*/
133-
static Status fromString(final String value) {
134-
return Arrays.stream(Status.values())
135-
.filter(stat -> stat.same(value))
136-
.findFirst()
137-
.orElseThrow(
138-
() -> new IllegalArgumentException(
139-
String.format("Invalid value %s for status", value)
140-
)
141-
);
142-
}
143-
144-
/**
145-
* Check if status is the same as value.
146-
* @param value Value.
147-
* @return True if status is the same as value.
148-
*/
149-
boolean same(final String value) {
150-
return this.status.equals(value.toLowerCase(Locale.ROOT));
151-
}
152-
}
153-
154-
/**
155-
* Check conclusion.
156-
* You can read more about it
157-
* @checkstyle LineLengthCheck (1 lines)
158-
* <a href="https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#list-check-runs-for-a-git-reference"> here </a>
159-
*/
160-
enum Conclusion {
161-
162-
/**
163-
* Action required.
164-
*/
165-
ACTION_REQUIRED("action_required"),
166-
167-
/**
168-
* Cancelled.
169-
*/
170-
CANCELLED("cancelled"),
171-
172-
/**
173-
* Failure.
174-
*/
175-
FAILURE("failure"),
176-
177-
/**
178-
* Neutral.
179-
*/
180-
NEUTRAL("neutral"),
181-
182-
/**
183-
* Success.
184-
*/
185-
SUCCESS("success"),
186-
187-
/**
188-
* Skipped.
189-
*/
190-
SKIPPED("skipped"),
191-
192-
/**
193-
* Stale.
194-
*/
195-
STALE("stale"),
196-
197-
/**
198-
* Timed out.
199-
*/
200-
TIMED_OUT("timed_out");
201-
202-
/**
203-
* Conclusion.
204-
*/
205-
private final String conclusion;
206-
207-
/**
208-
* Ctor.
209-
* @param con Conclusion.
210-
*/
211-
Conclusion(final String con) {
212-
this.conclusion = con;
213-
}
214-
215-
/**
216-
* Check if check is successful.
217-
* @return True if check is successful.
218-
*/
219-
boolean successful() {
220-
return this == Conclusion.SUCCESS;
221-
}
222-
223-
/**
224-
* Get conclusion from string.
225-
* @param value String value.
226-
* @return Conclusion.
227-
*/
228-
static Conclusion fromString(final String value) {
229-
return Arrays.stream(Conclusion.values())
230-
.filter(stat -> stat.same(value))
231-
.findFirst()
232-
.orElseThrow(
233-
() -> new IllegalArgumentException(
234-
String.format("Invalid value %s for conclusion", value)
235-
)
236-
);
237-
}
238-
239-
/**
240-
* Check if conclusion is the same as value.
241-
* @param value Value to compare.
242-
* @return True if conclusion is the same as value.
243-
*/
244-
boolean same(final String value) {
245-
return this.conclusion.equals(value.toLowerCase(Locale.ROOT));
246-
}
247-
}
24878
}

0 commit comments

Comments
 (0)