|
| 1 | +/* |
| 2 | + * Regula Document Reader Web API |
| 3 | + * Documents recognition as easy as reading two bytes. # Clients: * [JavaScript](https://github.com/regulaforensics/DocumentReader-web-js-client) client for the browser and node.js based on axios * [Java](https://github.com/regulaforensics/DocumentReader-web-java-client) client compatible with jvm and android * [Python](https://github.com/regulaforensics/DocumentReader-web-python-client) 3.5+ client * [C#](https://github.com/regulaforensics/DocumentReader-web-csharp-client) client for .NET & .NET Core |
| 4 | + * |
| 5 | + * The version of the OpenAPI document: 8.1.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 | +package com.regula.documentreader.webclient.model; |
| 14 | + |
| 15 | +import com.google.gson.Gson; |
| 16 | +import com.google.gson.JsonElement; |
| 17 | +import com.google.gson.JsonObject; |
| 18 | +import com.google.gson.TypeAdapter; |
| 19 | +import com.google.gson.TypeAdapterFactory; |
| 20 | +import com.google.gson.annotations.SerializedName; |
| 21 | +import com.google.gson.reflect.TypeToken; |
| 22 | +import com.google.gson.stream.JsonReader; |
| 23 | +import com.google.gson.stream.JsonWriter; |
| 24 | +import com.regula.documentreader.webclient.JSON; |
| 25 | +import java.io.IOException; |
| 26 | +import java.util.HashSet; |
| 27 | +import java.util.Objects; |
| 28 | + |
| 29 | +/** BarcodePositionItem */ |
| 30 | +@javax.annotation.Generated( |
| 31 | + value = "org.openapitools.codegen.languages.JavaClientCodegen", |
| 32 | + comments = "Generator version: 7.13.0") |
| 33 | +public class BarcodePositionItem { |
| 34 | + public static final String SERIALIZED_NAME_BARCODE_POSITION = "BarcodePosition"; |
| 35 | + |
| 36 | + @SerializedName(SERIALIZED_NAME_BARCODE_POSITION) |
| 37 | + @javax.annotation.Nonnull |
| 38 | + private DocumentPosition barcodePosition; |
| 39 | + |
| 40 | + public BarcodePositionItem() {} |
| 41 | + |
| 42 | + public BarcodePositionItem barcodePosition( |
| 43 | + @javax.annotation.Nonnull DocumentPosition barcodePosition) { |
| 44 | + this.barcodePosition = barcodePosition; |
| 45 | + return this; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Get barcodePosition |
| 50 | + * |
| 51 | + * @return barcodePosition |
| 52 | + */ |
| 53 | + @javax.annotation.Nonnull |
| 54 | + public DocumentPosition getBarcodePosition() { |
| 55 | + return barcodePosition; |
| 56 | + } |
| 57 | + |
| 58 | + public void setBarcodePosition(@javax.annotation.Nonnull DocumentPosition barcodePosition) { |
| 59 | + this.barcodePosition = barcodePosition; |
| 60 | + } |
| 61 | + |
| 62 | + @Override |
| 63 | + public boolean equals(Object o) { |
| 64 | + if (this == o) { |
| 65 | + return true; |
| 66 | + } |
| 67 | + if (o == null || getClass() != o.getClass()) { |
| 68 | + return false; |
| 69 | + } |
| 70 | + BarcodePositionItem barcodePositionItem = (BarcodePositionItem) o; |
| 71 | + return Objects.equals(this.barcodePosition, barcodePositionItem.barcodePosition); |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + public int hashCode() { |
| 76 | + return Objects.hash(barcodePosition); |
| 77 | + } |
| 78 | + |
| 79 | + @Override |
| 80 | + public String toString() { |
| 81 | + StringBuilder sb = new StringBuilder(); |
| 82 | + sb.append("class BarcodePositionItem {\n"); |
| 83 | + sb.append(" barcodePosition: ").append(toIndentedString(barcodePosition)).append("\n"); |
| 84 | + sb.append("}"); |
| 85 | + return sb.toString(); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Convert the given object to string with each line indented by 4 spaces (except the first line). |
| 90 | + */ |
| 91 | + private String toIndentedString(Object o) { |
| 92 | + if (o == null) { |
| 93 | + return "null"; |
| 94 | + } |
| 95 | + return o.toString().replace("\n", "\n "); |
| 96 | + } |
| 97 | + |
| 98 | + public static HashSet<String> openapiFields; |
| 99 | + public static HashSet<String> openapiRequiredFields; |
| 100 | + |
| 101 | + static { |
| 102 | + // a set of all properties/fields (JSON key names) |
| 103 | + openapiFields = new HashSet<String>(); |
| 104 | + openapiFields.add("BarcodePosition"); |
| 105 | + |
| 106 | + // a set of required properties/fields (JSON key names) |
| 107 | + openapiRequiredFields = new HashSet<String>(); |
| 108 | + openapiRequiredFields.add("BarcodePosition"); |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * Validates the JSON Element and throws an exception if issues found |
| 113 | + * |
| 114 | + * @param jsonElement JSON Element |
| 115 | + * @throws IOException if the JSON Element is invalid with respect to BarcodePositionItem |
| 116 | + */ |
| 117 | + public static void validateJsonElement(JsonElement jsonElement) throws IOException { |
| 118 | + if (jsonElement == null) { |
| 119 | + if (!BarcodePositionItem.openapiRequiredFields |
| 120 | + .isEmpty()) { // has required fields but JSON element is null |
| 121 | + throw new IllegalArgumentException( |
| 122 | + String.format( |
| 123 | + "The required field(s) %s in BarcodePositionItem is not found in the empty JSON string", |
| 124 | + BarcodePositionItem.openapiRequiredFields.toString())); |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + // check to make sure all required properties/fields are present in the JSON string |
| 129 | + for (String requiredField : BarcodePositionItem.openapiRequiredFields) { |
| 130 | + if (jsonElement.getAsJsonObject().get(requiredField) == null) { |
| 131 | + throw new IllegalArgumentException( |
| 132 | + String.format( |
| 133 | + "The required field `%s` is not found in the JSON string: %s", |
| 134 | + requiredField, jsonElement.toString())); |
| 135 | + } |
| 136 | + } |
| 137 | + JsonObject jsonObj = jsonElement.getAsJsonObject(); |
| 138 | + // validate the required field `BarcodePosition` |
| 139 | + DocumentPosition.validateJsonElement(jsonObj.get("BarcodePosition")); |
| 140 | + } |
| 141 | + |
| 142 | + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { |
| 143 | + @SuppressWarnings("unchecked") |
| 144 | + @Override |
| 145 | + public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { |
| 146 | + if (!BarcodePositionItem.class.isAssignableFrom(type.getRawType())) { |
| 147 | + return null; // this class only serializes 'BarcodePositionItem' and its subtypes |
| 148 | + } |
| 149 | + final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class); |
| 150 | + final TypeAdapter<BarcodePositionItem> thisAdapter = |
| 151 | + gson.getDelegateAdapter(this, TypeToken.get(BarcodePositionItem.class)); |
| 152 | + |
| 153 | + return (TypeAdapter<T>) |
| 154 | + new TypeAdapter<BarcodePositionItem>() { |
| 155 | + @Override |
| 156 | + public void write(JsonWriter out, BarcodePositionItem value) throws IOException { |
| 157 | + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); |
| 158 | + elementAdapter.write(out, obj); |
| 159 | + } |
| 160 | + |
| 161 | + @Override |
| 162 | + public BarcodePositionItem read(JsonReader in) throws IOException { |
| 163 | + JsonElement jsonElement = elementAdapter.read(in); |
| 164 | + validateJsonElement(jsonElement); |
| 165 | + return thisAdapter.fromJsonTree(jsonElement); |
| 166 | + } |
| 167 | + }.nullSafe(); |
| 168 | + } |
| 169 | + } |
| 170 | + |
| 171 | + /** |
| 172 | + * Create an instance of BarcodePositionItem given an JSON string |
| 173 | + * |
| 174 | + * @param jsonString JSON string |
| 175 | + * @return An instance of BarcodePositionItem |
| 176 | + * @throws IOException if the JSON string is invalid with respect to BarcodePositionItem |
| 177 | + */ |
| 178 | + public static BarcodePositionItem fromJson(String jsonString) throws IOException { |
| 179 | + return JSON.getGson().fromJson(jsonString, BarcodePositionItem.class); |
| 180 | + } |
| 181 | + |
| 182 | + /** |
| 183 | + * Convert an instance of BarcodePositionItem to an JSON string |
| 184 | + * |
| 185 | + * @return JSON string |
| 186 | + */ |
| 187 | + public String toJson() { |
| 188 | + return JSON.getGson().toJson(this); |
| 189 | + } |
| 190 | +} |
0 commit comments