|
| 1 | +/** |
| 2 | + * This file was auto-generated by Fern from our API Definition. |
| 3 | + */ |
| 4 | +package com.pipedream.api.types; |
| 5 | + |
| 6 | +import com.fasterxml.jackson.annotation.JsonValue; |
| 7 | +import com.fasterxml.jackson.core.JsonParseException; |
| 8 | +import com.fasterxml.jackson.core.JsonParser; |
| 9 | +import com.fasterxml.jackson.core.type.TypeReference; |
| 10 | +import com.fasterxml.jackson.databind.DeserializationContext; |
| 11 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
| 12 | +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; |
| 13 | +import com.pipedream.api.core.ObjectMappers; |
| 14 | +import java.io.IOException; |
| 15 | +import java.util.List; |
| 16 | +import java.util.Map; |
| 17 | +import java.util.Objects; |
| 18 | + |
| 19 | +@JsonDeserialize(using = ConfigurePropOptsConfiguredPropsValue.Deserializer.class) |
| 20 | +public final class ConfigurePropOptsConfiguredPropsValue { |
| 21 | + private final Object value; |
| 22 | + |
| 23 | + private final int type; |
| 24 | + |
| 25 | + private ConfigurePropOptsConfiguredPropsValue(Object value, int type) { |
| 26 | + this.value = value; |
| 27 | + this.type = type; |
| 28 | + } |
| 29 | + |
| 30 | + @JsonValue |
| 31 | + public Object get() { |
| 32 | + return this.value; |
| 33 | + } |
| 34 | + |
| 35 | + @SuppressWarnings("unchecked") |
| 36 | + public <T> T visit(Visitor<T> visitor) { |
| 37 | + if (this.type == 0) { |
| 38 | + return visitor.visit((Object) this.value); |
| 39 | + } else if (this.type == 1) { |
| 40 | + return visitor.visit((ConfiguredPropApp) this.value); |
| 41 | + } else if (this.type == 2) { |
| 42 | + return visitor.visit((ConfiguredPropSql) this.value); |
| 43 | + } else if (this.type == 3) { |
| 44 | + return visitor.visit((boolean) this.value); |
| 45 | + } else if (this.type == 4) { |
| 46 | + return visitor.visit((double) this.value); |
| 47 | + } else if (this.type == 5) { |
| 48 | + return visitor.visit((Map<String, Object>) this.value); |
| 49 | + } else if (this.type == 6) { |
| 50 | + return visitor.visit((String) this.value); |
| 51 | + } else if (this.type == 7) { |
| 52 | + return visitor.visit((List<String>) this.value); |
| 53 | + } |
| 54 | + throw new IllegalStateException("Failed to visit value. This should never happen."); |
| 55 | + } |
| 56 | + |
| 57 | + @java.lang.Override |
| 58 | + public boolean equals(Object other) { |
| 59 | + if (this == other) return true; |
| 60 | + return other instanceof ConfigurePropOptsConfiguredPropsValue |
| 61 | + && equalTo((ConfigurePropOptsConfiguredPropsValue) other); |
| 62 | + } |
| 63 | + |
| 64 | + private boolean equalTo(ConfigurePropOptsConfiguredPropsValue other) { |
| 65 | + return value.equals(other.value); |
| 66 | + } |
| 67 | + |
| 68 | + @java.lang.Override |
| 69 | + public int hashCode() { |
| 70 | + return Objects.hash(this.value); |
| 71 | + } |
| 72 | + |
| 73 | + @java.lang.Override |
| 74 | + public String toString() { |
| 75 | + return this.value.toString(); |
| 76 | + } |
| 77 | + |
| 78 | + public static ConfigurePropOptsConfiguredPropsValue of(Object value) { |
| 79 | + return new ConfigurePropOptsConfiguredPropsValue(value, 0); |
| 80 | + } |
| 81 | + |
| 82 | + public static ConfigurePropOptsConfiguredPropsValue of(ConfiguredPropApp value) { |
| 83 | + return new ConfigurePropOptsConfiguredPropsValue(value, 1); |
| 84 | + } |
| 85 | + |
| 86 | + public static ConfigurePropOptsConfiguredPropsValue of(ConfiguredPropSql value) { |
| 87 | + return new ConfigurePropOptsConfiguredPropsValue(value, 2); |
| 88 | + } |
| 89 | + |
| 90 | + public static ConfigurePropOptsConfiguredPropsValue of(boolean value) { |
| 91 | + return new ConfigurePropOptsConfiguredPropsValue(value, 3); |
| 92 | + } |
| 93 | + |
| 94 | + public static ConfigurePropOptsConfiguredPropsValue of(double value) { |
| 95 | + return new ConfigurePropOptsConfiguredPropsValue(value, 4); |
| 96 | + } |
| 97 | + |
| 98 | + public static ConfigurePropOptsConfiguredPropsValue of(Map<String, Object> value) { |
| 99 | + return new ConfigurePropOptsConfiguredPropsValue(value, 5); |
| 100 | + } |
| 101 | + |
| 102 | + public static ConfigurePropOptsConfiguredPropsValue of(String value) { |
| 103 | + return new ConfigurePropOptsConfiguredPropsValue(value, 6); |
| 104 | + } |
| 105 | + |
| 106 | + public static ConfigurePropOptsConfiguredPropsValue of(List<String> value) { |
| 107 | + return new ConfigurePropOptsConfiguredPropsValue(value, 7); |
| 108 | + } |
| 109 | + |
| 110 | + public interface Visitor<T> { |
| 111 | + T visit(Object value); |
| 112 | + |
| 113 | + T visit(ConfiguredPropApp value); |
| 114 | + |
| 115 | + T visit(ConfiguredPropSql value); |
| 116 | + |
| 117 | + T visit(boolean value); |
| 118 | + |
| 119 | + T visit(double value); |
| 120 | + |
| 121 | + T visit(Map<String, Object> value); |
| 122 | + |
| 123 | + T visit(String value); |
| 124 | + |
| 125 | + T visit(List<String> value); |
| 126 | + } |
| 127 | + |
| 128 | + static final class Deserializer extends StdDeserializer<ConfigurePropOptsConfiguredPropsValue> { |
| 129 | + Deserializer() { |
| 130 | + super(ConfigurePropOptsConfiguredPropsValue.class); |
| 131 | + } |
| 132 | + |
| 133 | + @java.lang.Override |
| 134 | + public ConfigurePropOptsConfiguredPropsValue deserialize(JsonParser p, DeserializationContext context) |
| 135 | + throws IOException { |
| 136 | + Object value = p.readValueAs(Object.class); |
| 137 | + try { |
| 138 | + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Object.class)); |
| 139 | + } catch (RuntimeException e) { |
| 140 | + } |
| 141 | + try { |
| 142 | + return of(ObjectMappers.JSON_MAPPER.convertValue(value, ConfiguredPropApp.class)); |
| 143 | + } catch (RuntimeException e) { |
| 144 | + } |
| 145 | + try { |
| 146 | + return of(ObjectMappers.JSON_MAPPER.convertValue(value, ConfiguredPropSql.class)); |
| 147 | + } catch (RuntimeException e) { |
| 148 | + } |
| 149 | + if (value instanceof Boolean) { |
| 150 | + return of((Boolean) value); |
| 151 | + } |
| 152 | + if (value instanceof Double) { |
| 153 | + return of((Double) value); |
| 154 | + } |
| 155 | + try { |
| 156 | + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference<Map<String, Object>>() {})); |
| 157 | + } catch (RuntimeException e) { |
| 158 | + } |
| 159 | + try { |
| 160 | + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); |
| 161 | + } catch (RuntimeException e) { |
| 162 | + } |
| 163 | + try { |
| 164 | + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference<List<String>>() {})); |
| 165 | + } catch (RuntimeException e) { |
| 166 | + } |
| 167 | + throw new JsonParseException(p, "Failed to deserialize"); |
| 168 | + } |
| 169 | + } |
| 170 | +} |
0 commit comments