|
| 1 | +/* |
| 2 | + * Unit OpenAPI specifications |
| 3 | + * An OpenAPI specifications for unit-sdk clients |
| 4 | + * |
| 5 | + * The version of the OpenAPI document: 0.2.0 |
| 6 | + * |
| 7 | + * |
| 8 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 9 | + * https://openapi-generator.tech |
| 10 | + * Do not edit the class manually. |
| 11 | + */ |
| 12 | + |
| 13 | + |
| 14 | +package org.openapitools.client.model; |
| 15 | + |
| 16 | +import java.util.Objects; |
| 17 | +import com.google.gson.TypeAdapter; |
| 18 | +import com.google.gson.annotations.JsonAdapter; |
| 19 | +import com.google.gson.annotations.SerializedName; |
| 20 | +import com.google.gson.stream.JsonReader; |
| 21 | +import com.google.gson.stream.JsonWriter; |
| 22 | +import java.io.IOException; |
| 23 | +import java.util.Arrays; |
| 24 | +import org.openapitools.client.model.Address; |
| 25 | + |
| 26 | +import com.google.gson.Gson; |
| 27 | +import com.google.gson.GsonBuilder; |
| 28 | +import com.google.gson.JsonArray; |
| 29 | +import com.google.gson.JsonDeserializationContext; |
| 30 | +import com.google.gson.JsonDeserializer; |
| 31 | +import com.google.gson.JsonElement; |
| 32 | +import com.google.gson.JsonObject; |
| 33 | +import com.google.gson.JsonParseException; |
| 34 | +import com.google.gson.TypeAdapterFactory; |
| 35 | +import com.google.gson.reflect.TypeToken; |
| 36 | +import com.google.gson.TypeAdapter; |
| 37 | +import com.google.gson.stream.JsonReader; |
| 38 | +import com.google.gson.stream.JsonWriter; |
| 39 | +import java.io.IOException; |
| 40 | + |
| 41 | +import java.lang.reflect.Type; |
| 42 | +import java.util.HashMap; |
| 43 | +import java.util.HashSet; |
| 44 | +import java.util.List; |
| 45 | +import java.util.Map; |
| 46 | +import java.util.Set; |
| 47 | + |
| 48 | +import org.openapitools.client.JSON; |
| 49 | + |
| 50 | +/** |
| 51 | + * CheckPaymentAttributesCounterparty |
| 52 | + */ |
| 53 | +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") |
| 54 | +public class CheckPaymentAttributesCounterparty { |
| 55 | + public static final String SERIALIZED_NAME_NAME = "name"; |
| 56 | + @SerializedName(SERIALIZED_NAME_NAME) |
| 57 | + private String name; |
| 58 | + |
| 59 | + public static final String SERIALIZED_NAME_ADDRESS = "address"; |
| 60 | + @SerializedName(SERIALIZED_NAME_ADDRESS) |
| 61 | + private Address address; |
| 62 | + |
| 63 | + public static final String SERIALIZED_NAME_COUNTERPARTY_MOVED = "counterpartyMoved"; |
| 64 | + @SerializedName(SERIALIZED_NAME_COUNTERPARTY_MOVED) |
| 65 | + private Boolean counterpartyMoved; |
| 66 | + |
| 67 | + public CheckPaymentAttributesCounterparty() { |
| 68 | + } |
| 69 | + |
| 70 | + public CheckPaymentAttributesCounterparty name(String name) { |
| 71 | + |
| 72 | + this.name = name; |
| 73 | + return this; |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Get name |
| 78 | + * @return name |
| 79 | + **/ |
| 80 | + @javax.annotation.Nullable |
| 81 | + public String getName() { |
| 82 | + return name; |
| 83 | + } |
| 84 | + |
| 85 | + |
| 86 | + public void setName(String name) { |
| 87 | + this.name = name; |
| 88 | + } |
| 89 | + |
| 90 | + |
| 91 | + public CheckPaymentAttributesCounterparty address(Address address) { |
| 92 | + |
| 93 | + this.address = address; |
| 94 | + return this; |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Get address |
| 99 | + * @return address |
| 100 | + **/ |
| 101 | + @javax.annotation.Nullable |
| 102 | + public Address getAddress() { |
| 103 | + return address; |
| 104 | + } |
| 105 | + |
| 106 | + |
| 107 | + public void setAddress(Address address) { |
| 108 | + this.address = address; |
| 109 | + } |
| 110 | + |
| 111 | + |
| 112 | + public CheckPaymentAttributesCounterparty counterpartyMoved(Boolean counterpartyMoved) { |
| 113 | + |
| 114 | + this.counterpartyMoved = counterpartyMoved; |
| 115 | + return this; |
| 116 | + } |
| 117 | + |
| 118 | + /** |
| 119 | + * Get counterpartyMoved |
| 120 | + * @return counterpartyMoved |
| 121 | + **/ |
| 122 | + @javax.annotation.Nullable |
| 123 | + public Boolean getCounterpartyMoved() { |
| 124 | + return counterpartyMoved; |
| 125 | + } |
| 126 | + |
| 127 | + |
| 128 | + public void setCounterpartyMoved(Boolean counterpartyMoved) { |
| 129 | + this.counterpartyMoved = counterpartyMoved; |
| 130 | + } |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + @Override |
| 135 | + public boolean equals(Object o) { |
| 136 | + if (this == o) { |
| 137 | + return true; |
| 138 | + } |
| 139 | + if (o == null || getClass() != o.getClass()) { |
| 140 | + return false; |
| 141 | + } |
| 142 | + CheckPaymentAttributesCounterparty checkPaymentAttributesCounterparty = (CheckPaymentAttributesCounterparty) o; |
| 143 | + return Objects.equals(this.name, checkPaymentAttributesCounterparty.name) && |
| 144 | + Objects.equals(this.address, checkPaymentAttributesCounterparty.address) && |
| 145 | + Objects.equals(this.counterpartyMoved, checkPaymentAttributesCounterparty.counterpartyMoved); |
| 146 | + } |
| 147 | + |
| 148 | + @Override |
| 149 | + public int hashCode() { |
| 150 | + return Objects.hash(name, address, counterpartyMoved); |
| 151 | + } |
| 152 | + |
| 153 | + @Override |
| 154 | + public String toString() { |
| 155 | + StringBuilder sb = new StringBuilder(); |
| 156 | + sb.append("class CheckPaymentAttributesCounterparty {\n"); |
| 157 | + sb.append(" name: ").append(toIndentedString(name)).append("\n"); |
| 158 | + sb.append(" address: ").append(toIndentedString(address)).append("\n"); |
| 159 | + sb.append(" counterpartyMoved: ").append(toIndentedString(counterpartyMoved)).append("\n"); |
| 160 | + sb.append("}"); |
| 161 | + return sb.toString(); |
| 162 | + } |
| 163 | + |
| 164 | + /** |
| 165 | + * Convert the given object to string with each line indented by 4 spaces |
| 166 | + * (except the first line). |
| 167 | + */ |
| 168 | + private String toIndentedString(Object o) { |
| 169 | + if (o == null) { |
| 170 | + return "null"; |
| 171 | + } |
| 172 | + return o.toString().replace("\n", "\n "); |
| 173 | + } |
| 174 | + |
| 175 | + |
| 176 | + public static HashSet<String> openapiFields; |
| 177 | + public static HashSet<String> openapiRequiredFields; |
| 178 | + |
| 179 | + static { |
| 180 | + // a set of all properties/fields (JSON key names) |
| 181 | + openapiFields = new HashSet<String>(); |
| 182 | + openapiFields.add("name"); |
| 183 | + openapiFields.add("address"); |
| 184 | + openapiFields.add("counterpartyMoved"); |
| 185 | + |
| 186 | + // a set of required properties/fields (JSON key names) |
| 187 | + openapiRequiredFields = new HashSet<String>(); |
| 188 | + } |
| 189 | + |
| 190 | + /** |
| 191 | + * Validates the JSON Element and throws an exception if issues found |
| 192 | + * |
| 193 | + * @param jsonElement JSON Element |
| 194 | + * @throws IOException if the JSON Element is invalid with respect to CheckPaymentAttributesCounterparty |
| 195 | + */ |
| 196 | + public static void validateJsonElement(JsonElement jsonElement) throws IOException { |
| 197 | + if (jsonElement == null) { |
| 198 | + if (!CheckPaymentAttributesCounterparty.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null |
| 199 | + throw new IllegalArgumentException(String.format("The required field(s) %s in CheckPaymentAttributesCounterparty is not found in the empty JSON string", CheckPaymentAttributesCounterparty.openapiRequiredFields.toString())); |
| 200 | + } |
| 201 | + } |
| 202 | + |
| 203 | + Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet(); |
| 204 | + // check to see if the JSON string contains additional fields |
| 205 | + for (Map.Entry<String, JsonElement> entry : entries) { |
| 206 | + if (!CheckPaymentAttributesCounterparty.openapiFields.contains(entry.getKey())) { |
| 207 | + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CheckPaymentAttributesCounterparty` properties. JSON: %s", entry.getKey(), jsonElement.toString())); |
| 208 | + } |
| 209 | + } |
| 210 | + JsonObject jsonObj = jsonElement.getAsJsonObject(); |
| 211 | + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { |
| 212 | + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); |
| 213 | + } |
| 214 | + // validate the optional field `address` |
| 215 | + if (jsonObj.get("address") != null && !jsonObj.get("address").isJsonNull()) { |
| 216 | + Address.validateJsonElement(jsonObj.get("address")); |
| 217 | + } |
| 218 | + } |
| 219 | + |
| 220 | + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { |
| 221 | + @SuppressWarnings("unchecked") |
| 222 | + @Override |
| 223 | + public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { |
| 224 | + if (!CheckPaymentAttributesCounterparty.class.isAssignableFrom(type.getRawType())) { |
| 225 | + return null; // this class only serializes 'CheckPaymentAttributesCounterparty' and its subtypes |
| 226 | + } |
| 227 | + final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class); |
| 228 | + final TypeAdapter<CheckPaymentAttributesCounterparty> thisAdapter |
| 229 | + = gson.getDelegateAdapter(this, TypeToken.get(CheckPaymentAttributesCounterparty.class)); |
| 230 | + |
| 231 | + return (TypeAdapter<T>) new TypeAdapter<CheckPaymentAttributesCounterparty>() { |
| 232 | + @Override |
| 233 | + public void write(JsonWriter out, CheckPaymentAttributesCounterparty value) throws IOException { |
| 234 | + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); |
| 235 | + elementAdapter.write(out, obj); |
| 236 | + } |
| 237 | + |
| 238 | + @Override |
| 239 | + public CheckPaymentAttributesCounterparty read(JsonReader in) throws IOException { |
| 240 | + JsonElement jsonElement = elementAdapter.read(in); |
| 241 | + validateJsonElement(jsonElement); |
| 242 | + return thisAdapter.fromJsonTree(jsonElement); |
| 243 | + } |
| 244 | + |
| 245 | + }.nullSafe(); |
| 246 | + } |
| 247 | + } |
| 248 | + |
| 249 | + /** |
| 250 | + * Create an instance of CheckPaymentAttributesCounterparty given an JSON string |
| 251 | + * |
| 252 | + * @param jsonString JSON string |
| 253 | + * @return An instance of CheckPaymentAttributesCounterparty |
| 254 | + * @throws IOException if the JSON string is invalid with respect to CheckPaymentAttributesCounterparty |
| 255 | + */ |
| 256 | + public static CheckPaymentAttributesCounterparty fromJson(String jsonString) throws IOException { |
| 257 | + return JSON.getGson().fromJson(jsonString, CheckPaymentAttributesCounterparty.class); |
| 258 | + } |
| 259 | + |
| 260 | + /** |
| 261 | + * Convert an instance of CheckPaymentAttributesCounterparty to an JSON string |
| 262 | + * |
| 263 | + * @return JSON string |
| 264 | + */ |
| 265 | + public String toJson() { |
| 266 | + return JSON.getGson().toJson(this); |
| 267 | + } |
| 268 | +} |
| 269 | + |
0 commit comments