|
| 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 | +/** RemoveAudienceFromSpace200Response1 */ |
| 31 | +public class RemoveAudienceFromSpace200Response1 { |
| 32 | + public static final String SERIALIZED_NAME_DATA = "data"; |
| 33 | + |
| 34 | + @SerializedName(SERIALIZED_NAME_DATA) |
| 35 | + private RemoveAudienceFromSpaceAlphaOutput data; |
| 36 | + |
| 37 | + public RemoveAudienceFromSpace200Response1() {} |
| 38 | + |
| 39 | + public RemoveAudienceFromSpace200Response1 data(RemoveAudienceFromSpaceAlphaOutput 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 RemoveAudienceFromSpaceAlphaOutput getData() { |
| 52 | + return data; |
| 53 | + } |
| 54 | + |
| 55 | + public void setData(RemoveAudienceFromSpaceAlphaOutput 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 | + RemoveAudienceFromSpace200Response1 removeAudienceFromSpace200Response1 = |
| 68 | + (RemoveAudienceFromSpace200Response1) o; |
| 69 | + return Objects.equals(this.data, removeAudienceFromSpace200Response1.data); |
| 70 | + } |
| 71 | + |
| 72 | + @Override |
| 73 | + public int hashCode() { |
| 74 | + return Objects.hash(data); |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public String toString() { |
| 79 | + StringBuilder sb = new StringBuilder(); |
| 80 | + sb.append("class RemoveAudienceFromSpace200Response1 {\n"); |
| 81 | + sb.append(" data: ").append(toIndentedString(data)).append("\n"); |
| 82 | + sb.append("}"); |
| 83 | + return sb.toString(); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Convert the given object to string with each line indented by 4 spaces (except the first |
| 88 | + * line). |
| 89 | + */ |
| 90 | + private String toIndentedString(Object o) { |
| 91 | + if (o == null) { |
| 92 | + return "null"; |
| 93 | + } |
| 94 | + return o.toString().replace("\n", "\n "); |
| 95 | + } |
| 96 | + |
| 97 | + public static HashSet<String> openapiFields; |
| 98 | + public static HashSet<String> openapiRequiredFields; |
| 99 | + |
| 100 | + static { |
| 101 | + // a set of all properties/fields (JSON key names) |
| 102 | + openapiFields = new HashSet<String>(); |
| 103 | + openapiFields.add("data"); |
| 104 | + |
| 105 | + // a set of required properties/fields (JSON key names) |
| 106 | + openapiRequiredFields = new HashSet<String>(); |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * Validates the JSON Element and throws an exception if issues found |
| 111 | + * |
| 112 | + * @param jsonElement JSON Element |
| 113 | + * @throws IOException if the JSON Element is invalid with respect to |
| 114 | + * RemoveAudienceFromSpace200Response1 |
| 115 | + */ |
| 116 | + public static void validateJsonElement(JsonElement jsonElement) throws IOException { |
| 117 | + if (jsonElement == null) { |
| 118 | + if (!RemoveAudienceFromSpace200Response1.openapiRequiredFields |
| 119 | + .isEmpty()) { // has required fields but JSON element is null |
| 120 | + throw new IllegalArgumentException( |
| 121 | + String.format( |
| 122 | + "The required field(s) %s in RemoveAudienceFromSpace200Response1 is" |
| 123 | + + " not found in the empty JSON string", |
| 124 | + RemoveAudienceFromSpace200Response1.openapiRequiredFields |
| 125 | + .toString())); |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | + Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet(); |
| 130 | + // check to see if the JSON string contains additional fields |
| 131 | + for (Map.Entry<String, JsonElement> entry : entries) { |
| 132 | + if (!RemoveAudienceFromSpace200Response1.openapiFields.contains(entry.getKey())) { |
| 133 | + throw new IllegalArgumentException( |
| 134 | + String.format( |
| 135 | + "The field `%s` in the JSON string is not defined in the" |
| 136 | + + " `RemoveAudienceFromSpace200Response1` properties. JSON: %s", |
| 137 | + entry.getKey(), jsonElement.toString())); |
| 138 | + } |
| 139 | + } |
| 140 | + JsonObject jsonObj = jsonElement.getAsJsonObject(); |
| 141 | + // validate the optional field `data` |
| 142 | + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { |
| 143 | + RemoveAudienceFromSpaceAlphaOutput.validateJsonElement(jsonObj.get("data")); |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { |
| 148 | + @SuppressWarnings("unchecked") |
| 149 | + @Override |
| 150 | + public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { |
| 151 | + if (!RemoveAudienceFromSpace200Response1.class.isAssignableFrom(type.getRawType())) { |
| 152 | + return null; // this class only serializes 'RemoveAudienceFromSpace200Response1' and |
| 153 | + // its subtypes |
| 154 | + } |
| 155 | + final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class); |
| 156 | + final TypeAdapter<RemoveAudienceFromSpace200Response1> thisAdapter = |
| 157 | + gson.getDelegateAdapter( |
| 158 | + this, TypeToken.get(RemoveAudienceFromSpace200Response1.class)); |
| 159 | + |
| 160 | + return (TypeAdapter<T>) |
| 161 | + new TypeAdapter<RemoveAudienceFromSpace200Response1>() { |
| 162 | + @Override |
| 163 | + public void write(JsonWriter out, RemoveAudienceFromSpace200Response1 value) |
| 164 | + throws IOException { |
| 165 | + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); |
| 166 | + elementAdapter.write(out, obj); |
| 167 | + } |
| 168 | + |
| 169 | + @Override |
| 170 | + public RemoveAudienceFromSpace200Response1 read(JsonReader in) |
| 171 | + throws IOException { |
| 172 | + JsonElement jsonElement = elementAdapter.read(in); |
| 173 | + validateJsonElement(jsonElement); |
| 174 | + return thisAdapter.fromJsonTree(jsonElement); |
| 175 | + } |
| 176 | + }.nullSafe(); |
| 177 | + } |
| 178 | + } |
| 179 | + |
| 180 | + /** |
| 181 | + * Create an instance of RemoveAudienceFromSpace200Response1 given an JSON string |
| 182 | + * |
| 183 | + * @param jsonString JSON string |
| 184 | + * @return An instance of RemoveAudienceFromSpace200Response1 |
| 185 | + * @throws IOException if the JSON string is invalid with respect to |
| 186 | + * RemoveAudienceFromSpace200Response1 |
| 187 | + */ |
| 188 | + public static RemoveAudienceFromSpace200Response1 fromJson(String jsonString) |
| 189 | + throws IOException { |
| 190 | + return JSON.getGson().fromJson(jsonString, RemoveAudienceFromSpace200Response1.class); |
| 191 | + } |
| 192 | + |
| 193 | + /** |
| 194 | + * Convert an instance of RemoveAudienceFromSpace200Response1 to an JSON string |
| 195 | + * |
| 196 | + * @return JSON string |
| 197 | + */ |
| 198 | + public String toJson() { |
| 199 | + return JSON.getGson().toJson(this); |
| 200 | + } |
| 201 | +} |
0 commit comments