66import com .fasterxml .jackson .annotation .JsonValue ;
77import com .fasterxml .jackson .core .JsonParseException ;
88import com .fasterxml .jackson .core .JsonParser ;
9+ import com .fasterxml .jackson .core .type .TypeReference ;
910import com .fasterxml .jackson .databind .DeserializationContext ;
1011import com .fasterxml .jackson .databind .annotation .JsonDeserialize ;
1112import com .fasterxml .jackson .databind .deser .std .StdDeserializer ;
1213import com .pipedream .api .core .ObjectMappers ;
1314import java .io .IOException ;
1415import java .util .Objects ;
16+ import java .util .Optional ;
1517
1618@ JsonDeserialize (using = RunActionOptsStashId .Deserializer .class )
1719public final class RunActionOptsStashId {
@@ -32,8 +34,10 @@ public Object get() {
3234 @ SuppressWarnings ("unchecked" )
3335 public <T > T visit (Visitor <T > visitor ) {
3436 if (this .type == 0 ) {
35- return visitor .visit ((String ) this .value );
37+ return visitor .visit ((Optional < String > ) this .value );
3638 } else if (this .type == 1 ) {
39+ return visitor .visit ((String ) this .value );
40+ } else if (this .type == 2 ) {
3741 return visitor .visit ((boolean ) this .value );
3842 }
3943 throw new IllegalStateException ("Failed to visit value. This should never happen." );
@@ -59,15 +63,33 @@ public String toString() {
5963 return this .value .toString ();
6064 }
6165
62- public static RunActionOptsStashId of (String value ) {
66+ public static RunActionOptsStashId of (Optional < String > value ) {
6367 return new RunActionOptsStashId (value , 0 );
6468 }
6569
66- public static RunActionOptsStashId of (boolean value ) {
70+ /**
71+ * @param value must be one of the following:
72+ * <ul>
73+ * <li>"NEW"</li>
74+ * </ul>
75+ */
76+ public static RunActionOptsStashId of (String value ) {
6777 return new RunActionOptsStashId (value , 1 );
6878 }
6979
80+ public static RunActionOptsStashId of (boolean value ) {
81+ return new RunActionOptsStashId (value , 2 );
82+ }
83+
7084 public interface Visitor <T > {
85+ T visit (Optional <String > value );
86+
87+ /**
88+ * @param value must be one of the following:
89+ * <ul>
90+ * <li>"NEW"</li>
91+ * </ul>
92+ */
7193 T visit (String value );
7294
7395 T visit (boolean value );
@@ -81,6 +103,10 @@ static final class Deserializer extends StdDeserializer<RunActionOptsStashId> {
81103 @ java .lang .Override
82104 public RunActionOptsStashId deserialize (JsonParser p , DeserializationContext context ) throws IOException {
83105 Object value = p .readValueAs (Object .class );
106+ try {
107+ return of (ObjectMappers .JSON_MAPPER .convertValue (value , new TypeReference <Optional <String >>() {}));
108+ } catch (IllegalArgumentException e ) {
109+ }
84110 try {
85111 return of (ObjectMappers .JSON_MAPPER .convertValue (value , String .class ));
86112 } catch (IllegalArgumentException e ) {
0 commit comments