11package org .kohsuke .github ;
22
33import com .fasterxml .jackson .annotation .JsonProperty ;
4+ import com .infradna .tool .bridge_method_injector .WithBridgeMethods ;
45import edu .umd .cs .findbugs .annotations .NonNull ;
56import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
7+ import org .kohsuke .github .GHWorkflowRun .Conclusion ;
8+ import org .kohsuke .github .GHWorkflowRun .Status ;
9+ import org .kohsuke .github .internal .EnumUtils ;
610import org .kohsuke .github .internal .Previews ;
711
812import java .io .IOException ;
1115import java .util .Collections ;
1216import java .util .Date ;
1317import java .util .List ;
18+ import java .util .Locale ;
1419
1520/**
1621 * Represents a check run.
@@ -80,12 +85,27 @@ GHPullRequest[] wrap() {
8085 * @return Status of the check run
8186 * @see Status
8287 */
83- public String getStatus () {
88+ @ WithBridgeMethods (value = String .class , adapterMethod = "statusAsStr" )
89+ public Status getStatus () {
90+ return Status .from (status );
91+ }
92+
93+ @ SuppressFBWarnings (value = "UPM_UNCALLED_PRIVATE_METHOD" , justification = "Bridge method of getStatus" )
94+ private Object statusAsStr (Status status , Class type ) {
8495 return status ;
8596 }
8697
8798 public static enum Status {
88- QUEUED , IN_PROGRESS , COMPLETED
99+ QUEUED , IN_PROGRESS , COMPLETED , UNKNOWN ;
100+
101+ public static Status from (String value ) {
102+ return EnumUtils .getEnum (Status .class , value , Status .UNKNOWN );
103+ }
104+
105+ @ Override
106+ public String toString () {
107+ return name ().toLowerCase (Locale .ROOT );
108+ }
89109 }
90110
91111 /**
@@ -94,7 +114,13 @@ public static enum Status {
94114 * @return Status of the check run
95115 * @see Conclusion
96116 */
97- public String getConclusion () {
117+ @ WithBridgeMethods (value = String .class , adapterMethod = "conclusionAsStr" )
118+ public Conclusion getConclusion () {
119+ return Conclusion .from (conclusion );
120+ }
121+
122+ @ SuppressFBWarnings (value = "UPM_UNCALLED_PRIVATE_METHOD" , justification = "Bridge method of getConclusion" )
123+ private Object conclusionAsStr (Conclusion conclusion , Class type ) {
98124 return conclusion ;
99125 }
100126
@@ -105,7 +131,16 @@ public String getConclusion() {
105131 * Parameters - <code>conclusion</code></a>.
106132 */
107133 public static enum Conclusion {
108- SUCCESS , FAILURE , NEUTRAL , CANCELLED , TIMED_OUT , ACTION_REQUIRED , SKIPPED
134+ ACTION_REQUIRED , CANCELLED , FAILURE , NEUTRAL , SUCCESS , SKIPPED , STALE , TIMED_OUT , UNKNOWN ;
135+
136+ public static Conclusion from (String value ) {
137+ return EnumUtils .getEnum (Conclusion .class , value , Conclusion .UNKNOWN );
138+ }
139+
140+ @ Override
141+ public String toString () {
142+ return name ().toLowerCase (Locale .ROOT );
143+ }
109144 }
110145
111146 /**
0 commit comments