|
| 1 | +/* |
| 2 | + * Segment Public API |
| 3 | + * The Segment Public API helps you manage your Segment Workspaces and its resources. You can use the API to perform CRUD (create, read, update, delete) operations at no extra charge. This includes working with resources such as Sources, Destinations, Warehouses, Tracking Plans, and the Segment Destinations and Sources Catalogs. All CRUD endpoints in the API follow REST conventions and use standard HTTP methods. Different URL endpoints represent different resources in a Workspace. See the next sections for more information on how to use the Segment Public API. |
| 4 | + * |
| 5 | + |
| 6 | + * |
| 7 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 8 | + * https://openapi-generator.tech |
| 9 | + * Do not edit the class manually. |
| 10 | + */ |
| 11 | + |
| 12 | +package com.segment.publicapi.models; |
| 13 | + |
| 14 | +import com.google.gson.Gson; |
| 15 | +import com.google.gson.JsonElement; |
| 16 | +import com.google.gson.JsonObject; |
| 17 | +import com.google.gson.TypeAdapter; |
| 18 | +import com.google.gson.TypeAdapterFactory; |
| 19 | +import com.google.gson.annotations.SerializedName; |
| 20 | +import com.google.gson.reflect.TypeToken; |
| 21 | +import com.google.gson.stream.JsonReader; |
| 22 | +import com.google.gson.stream.JsonWriter; |
| 23 | +import com.segment.publicapi.JSON; |
| 24 | +import java.io.IOException; |
| 25 | +import java.util.HashSet; |
| 26 | +import java.util.Map; |
| 27 | +import java.util.Objects; |
| 28 | +import java.util.Set; |
| 29 | + |
| 30 | +/** ListAudiences200Response1 */ |
| 31 | +public class ListAudiences200Response1 { |
| 32 | + public static final String SERIALIZED_NAME_DATA = "data"; |
| 33 | + |
| 34 | + @SerializedName(SERIALIZED_NAME_DATA) |
| 35 | + private ListAudiencesAlphaOutput data; |
| 36 | + |
| 37 | + public ListAudiences200Response1() {} |
| 38 | + |
| 39 | + public ListAudiences200Response1 data(ListAudiencesAlphaOutput data) { |
| 40 | + |
| 41 | + this.data = data; |
| 42 | + return this; |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Get data |
| 47 | + * |
| 48 | + * @return data |
| 49 | + */ |
| 50 | + @javax.annotation.Nullable |
| 51 | + public ListAudiencesAlphaOutput getData() { |
| 52 | + return data; |
| 53 | + } |
| 54 | + |
| 55 | + public void setData(ListAudiencesAlphaOutput data) { |
| 56 | + this.data = data; |
| 57 | + } |
| 58 | + |
| 59 | + @Override |
| 60 | + public boolean equals(Object o) { |
| 61 | + if (this == o) { |
| 62 | + return true; |
| 63 | + } |
| 64 | + if (o == null || getClass() != o.getClass()) { |
| 65 | + return false; |
| 66 | + } |
| 67 | + ListAudiences200Response1 listAudiences200Response1 = (ListAudiences200Response1) o; |
| 68 | + return Objects.equals(this.data, listAudiences200Response1.data); |
| 69 | + } |
| 70 | + |
| 71 | + @Override |
| 72 | + public int hashCode() { |
| 73 | + return Objects.hash(data); |
| 74 | + } |
| 75 | + |
| 76 | + @Override |
| 77 | + public String toString() { |
| 78 | + StringBuilder sb = new StringBuilder(); |
| 79 | + sb.append("class ListAudiences200Response1 {\n"); |
| 80 | + sb.append(" data: ").append(toIndentedString(data)).append("\n"); |
| 81 | + sb.append("}"); |
| 82 | + return sb.toString(); |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Convert the given object to string with each line indented by 4 spaces (except the first |
| 87 | + * line). |
| 88 | + */ |
| 89 | + private String toIndentedString(Object o) { |
| 90 | + if (o == null) { |
| 91 | + return "null"; |
| 92 | + } |
| 93 | + return o.toString().replace("\n", "\n "); |
| 94 | + } |
| 95 | + |
| 96 | + public static HashSet<String> openapiFields; |
| 97 | + public static HashSet<String> openapiRequiredFields; |
| 98 | + |
| 99 | + static { |
| 100 | + // a set of all properties/fields (JSON key names) |
| 101 | + openapiFields = new HashSet<String>(); |
| 102 | + openapiFields.add("data"); |
| 103 | + |
| 104 | + // a set of required properties/fields (JSON key names) |
| 105 | + openapiRequiredFields = new HashSet<String>(); |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Validates the JSON Element and throws an exception if issues found |
| 110 | + * |
| 111 | + * @param jsonElement JSON Element |
| 112 | + * @throws IOException if the JSON Element is invalid with respect to ListAudiences200Response1 |
| 113 | + */ |
| 114 | + public static void validateJsonElement(JsonElement jsonElement) throws IOException { |
| 115 | + if (jsonElement == null) { |
| 116 | + if (!ListAudiences200Response1.openapiRequiredFields |
| 117 | + .isEmpty()) { // has required fields but JSON element is null |
| 118 | + throw new IllegalArgumentException( |
| 119 | + String.format( |
| 120 | + "The required field(s) %s in ListAudiences200Response1 is not found" |
| 121 | + + " in the empty JSON string", |
| 122 | + ListAudiences200Response1.openapiRequiredFields.toString())); |
| 123 | + } |
| 124 | + } |
| 125 | + |
| 126 | + Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet(); |
| 127 | + // check to see if the JSON string contains additional fields |
| 128 | + for (Map.Entry<String, JsonElement> entry : entries) { |
| 129 | + if (!ListAudiences200Response1.openapiFields.contains(entry.getKey())) { |
| 130 | + throw new IllegalArgumentException( |
| 131 | + String.format( |
| 132 | + "The field `%s` in the JSON string is not defined in the" |
| 133 | + + " `ListAudiences200Response1` properties. JSON: %s", |
| 134 | + entry.getKey(), jsonElement.toString())); |
| 135 | + } |
| 136 | + } |
| 137 | + JsonObject jsonObj = jsonElement.getAsJsonObject(); |
| 138 | + // validate the optional field `data` |
| 139 | + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { |
| 140 | + ListAudiencesAlphaOutput.validateJsonElement(jsonObj.get("data")); |
| 141 | + } |
| 142 | + } |
| 143 | + |
| 144 | + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { |
| 145 | + @SuppressWarnings("unchecked") |
| 146 | + @Override |
| 147 | + public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { |
| 148 | + if (!ListAudiences200Response1.class.isAssignableFrom(type.getRawType())) { |
| 149 | + return null; // this class only serializes 'ListAudiences200Response1' and its |
| 150 | + // subtypes |
| 151 | + } |
| 152 | + final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class); |
| 153 | + final TypeAdapter<ListAudiences200Response1> thisAdapter = |
| 154 | + gson.getDelegateAdapter(this, TypeToken.get(ListAudiences200Response1.class)); |
| 155 | + |
| 156 | + return (TypeAdapter<T>) |
| 157 | + new TypeAdapter<ListAudiences200Response1>() { |
| 158 | + @Override |
| 159 | + public void write(JsonWriter out, ListAudiences200Response1 value) |
| 160 | + throws IOException { |
| 161 | + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); |
| 162 | + elementAdapter.write(out, obj); |
| 163 | + } |
| 164 | + |
| 165 | + @Override |
| 166 | + public ListAudiences200Response1 read(JsonReader in) throws IOException { |
| 167 | + JsonElement jsonElement = elementAdapter.read(in); |
| 168 | + validateJsonElement(jsonElement); |
| 169 | + return thisAdapter.fromJsonTree(jsonElement); |
| 170 | + } |
| 171 | + }.nullSafe(); |
| 172 | + } |
| 173 | + } |
| 174 | + |
| 175 | + /** |
| 176 | + * Create an instance of ListAudiences200Response1 given an JSON string |
| 177 | + * |
| 178 | + * @param jsonString JSON string |
| 179 | + * @return An instance of ListAudiences200Response1 |
| 180 | + * @throws IOException if the JSON string is invalid with respect to ListAudiences200Response1 |
| 181 | + */ |
| 182 | + public static ListAudiences200Response1 fromJson(String jsonString) throws IOException { |
| 183 | + return JSON.getGson().fromJson(jsonString, ListAudiences200Response1.class); |
| 184 | + } |
| 185 | + |
| 186 | + /** |
| 187 | + * Convert an instance of ListAudiences200Response1 to an JSON string |
| 188 | + * |
| 189 | + * @return JSON string |
| 190 | + */ |
| 191 | + public String toJson() { |
| 192 | + return JSON.getGson().toJson(this); |
| 193 | + } |
| 194 | +} |
0 commit comments