getValue() {
return value;
}
@@ -77,24 +79,24 @@ public interface LabelStage {
/**
* The human-readable label for the option
*/
- ValueStage label(@NotNull String label);
+ _FinalStage label(@NotNull String label);
Builder from(PropOption other);
}
- public interface ValueStage {
- _FinalStage value(Object value);
- }
-
public interface _FinalStage {
PropOption build();
+
+ _FinalStage value(Optional value);
+
+ _FinalStage value(PropOptionValue value);
}
@JsonIgnoreProperties(ignoreUnknown = true)
- public static final class Builder implements LabelStage, ValueStage, _FinalStage {
+ public static final class Builder implements LabelStage, _FinalStage {
private String label;
- private Object value;
+ private Optional value = Optional.empty();
@JsonAnySetter
private Map additionalProperties = new HashMap<>();
@@ -115,14 +117,20 @@ public Builder from(PropOption other) {
*/
@java.lang.Override
@JsonSetter("label")
- public ValueStage label(@NotNull String label) {
+ public _FinalStage label(@NotNull String label) {
this.label = Objects.requireNonNull(label, "label must not be null");
return this;
}
@java.lang.Override
- @JsonSetter("value")
- public _FinalStage value(Object value) {
+ public _FinalStage value(PropOptionValue value) {
+ this.value = Optional.ofNullable(value);
+ return this;
+ }
+
+ @java.lang.Override
+ @JsonSetter(value = "value", nulls = Nulls.SKIP)
+ public _FinalStage value(Optional value) {
this.value = value;
return this;
}
diff --git a/src/main/java/com/pipedream/api/types/PropOptionValue.java b/src/main/java/com/pipedream/api/types/PropOptionValue.java
new file mode 100644
index 0000000..4ccaf0b
--- /dev/null
+++ b/src/main/java/com/pipedream/api/types/PropOptionValue.java
@@ -0,0 +1,105 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.pipedream.api.types;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+import com.pipedream.api.core.ObjectMappers;
+import java.io.IOException;
+import java.util.Objects;
+
+@JsonDeserialize(using = PropOptionValue.Deserializer.class)
+public final class PropOptionValue {
+ private final Object value;
+
+ private final int type;
+
+ private PropOptionValue(Object value, int type) {
+ this.value = value;
+ this.type = type;
+ }
+
+ @JsonValue
+ public Object get() {
+ return this.value;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T visit(Visitor visitor) {
+ if (this.type == 0) {
+ return visitor.visit((String) this.value);
+ } else if (this.type == 1) {
+ return visitor.visit((int) this.value);
+ } else if (this.type == 2) {
+ return visitor.visit((boolean) this.value);
+ }
+ throw new IllegalStateException("Failed to visit value. This should never happen.");
+ }
+
+ @java.lang.Override
+ public boolean equals(Object other) {
+ if (this == other) return true;
+ return other instanceof PropOptionValue && equalTo((PropOptionValue) other);
+ }
+
+ private boolean equalTo(PropOptionValue other) {
+ return value.equals(other.value);
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ return Objects.hash(this.value);
+ }
+
+ @java.lang.Override
+ public String toString() {
+ return this.value.toString();
+ }
+
+ public static PropOptionValue of(String value) {
+ return new PropOptionValue(value, 0);
+ }
+
+ public static PropOptionValue of(int value) {
+ return new PropOptionValue(value, 1);
+ }
+
+ public static PropOptionValue of(boolean value) {
+ return new PropOptionValue(value, 2);
+ }
+
+ public interface Visitor {
+ T visit(String value);
+
+ T visit(int value);
+
+ T visit(boolean value);
+ }
+
+ static final class Deserializer extends StdDeserializer {
+ Deserializer() {
+ super(PropOptionValue.class);
+ }
+
+ @java.lang.Override
+ public PropOptionValue deserialize(JsonParser p, DeserializationContext context) throws IOException {
+ Object value = p.readValueAs(Object.class);
+ try {
+ return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class));
+ } catch (RuntimeException e) {
+ }
+ if (value instanceof Integer) {
+ return of((Integer) value);
+ }
+ if (value instanceof Boolean) {
+ return of((Boolean) value);
+ }
+ throw new JsonParseException(p, "Failed to deserialize");
+ }
+ }
+}