|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | +// Code generated by Microsoft (R) TypeSpec Code Generator. |
| 4 | + |
| 5 | +package com.azure.ai.documentintelligence.models; |
| 6 | + |
| 7 | +import com.azure.core.annotation.Fluent; |
| 8 | +import com.azure.core.annotation.Generated; |
| 9 | +import com.azure.json.JsonReader; |
| 10 | +import com.azure.json.JsonSerializable; |
| 11 | +import com.azure.json.JsonToken; |
| 12 | +import com.azure.json.JsonWriter; |
| 13 | +import java.io.IOException; |
| 14 | +import java.util.Map; |
| 15 | + |
| 16 | +/** |
| 17 | + * Request body to create a composed document model from component document models. |
| 18 | + */ |
| 19 | +@Fluent |
| 20 | +public final class ComposeDocumentModelOptions implements JsonSerializable<ComposeDocumentModelOptions> { |
| 21 | + /* |
| 22 | + * Unique document model name. |
| 23 | + */ |
| 24 | + @Generated |
| 25 | + private final String modelId; |
| 26 | + |
| 27 | + /* |
| 28 | + * Document model description. |
| 29 | + */ |
| 30 | + @Generated |
| 31 | + private String description; |
| 32 | + |
| 33 | + /* |
| 34 | + * Custom classifier to split and classify the input file. |
| 35 | + */ |
| 36 | + @Generated |
| 37 | + private final String classifierId; |
| 38 | + |
| 39 | + /* |
| 40 | + * File splitting behavior. |
| 41 | + */ |
| 42 | + @Generated |
| 43 | + private SplitMode split; |
| 44 | + |
| 45 | + /* |
| 46 | + * Dictionary mapping supported docTypes to the corresponding document models. |
| 47 | + */ |
| 48 | + @Generated |
| 49 | + private final Map<String, DocumentTypeDetails> documentTypes; |
| 50 | + |
| 51 | + /* |
| 52 | + * List of key-value tag attributes associated with the document model. |
| 53 | + */ |
| 54 | + @Generated |
| 55 | + private Map<String, String> tags; |
| 56 | + |
| 57 | + /** |
| 58 | + * Creates an instance of ComposeDocumentModelOptions class. |
| 59 | + * |
| 60 | + * @param modelId the modelId value to set. |
| 61 | + * @param classifierId the classifierId value to set. |
| 62 | + * @param documentTypes the documentTypes value to set. |
| 63 | + */ |
| 64 | + @Generated |
| 65 | + public ComposeDocumentModelOptions(String modelId, String classifierId, |
| 66 | + Map<String, DocumentTypeDetails> documentTypes) { |
| 67 | + this.modelId = modelId; |
| 68 | + this.classifierId = classifierId; |
| 69 | + this.documentTypes = documentTypes; |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Get the modelId property: Unique document model name. |
| 74 | + * |
| 75 | + * @return the modelId value. |
| 76 | + */ |
| 77 | + @Generated |
| 78 | + public String getModelId() { |
| 79 | + return this.modelId; |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Get the description property: Document model description. |
| 84 | + * |
| 85 | + * @return the description value. |
| 86 | + */ |
| 87 | + @Generated |
| 88 | + public String getDescription() { |
| 89 | + return this.description; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Set the description property: Document model description. |
| 94 | + * |
| 95 | + * @param description the description value to set. |
| 96 | + * @return the ComposeDocumentModelOptions object itself. |
| 97 | + */ |
| 98 | + @Generated |
| 99 | + public ComposeDocumentModelOptions setDescription(String description) { |
| 100 | + this.description = description; |
| 101 | + return this; |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * Get the classifierId property: Custom classifier to split and classify the input file. |
| 106 | + * |
| 107 | + * @return the classifierId value. |
| 108 | + */ |
| 109 | + @Generated |
| 110 | + public String getClassifierId() { |
| 111 | + return this.classifierId; |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Get the split property: File splitting behavior. |
| 116 | + * |
| 117 | + * @return the split value. |
| 118 | + */ |
| 119 | + @Generated |
| 120 | + public SplitMode getSplit() { |
| 121 | + return this.split; |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Set the split property: File splitting behavior. |
| 126 | + * |
| 127 | + * @param split the split value to set. |
| 128 | + * @return the ComposeDocumentModelOptions object itself. |
| 129 | + */ |
| 130 | + @Generated |
| 131 | + public ComposeDocumentModelOptions setSplit(SplitMode split) { |
| 132 | + this.split = split; |
| 133 | + return this; |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * Get the documentTypes property: Dictionary mapping supported docTypes to the corresponding document models. |
| 138 | + * |
| 139 | + * @return the documentTypes value. |
| 140 | + */ |
| 141 | + @Generated |
| 142 | + public Map<String, DocumentTypeDetails> getDocumentTypes() { |
| 143 | + return this.documentTypes; |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * Get the tags property: List of key-value tag attributes associated with the document model. |
| 148 | + * |
| 149 | + * @return the tags value. |
| 150 | + */ |
| 151 | + @Generated |
| 152 | + public Map<String, String> getTags() { |
| 153 | + return this.tags; |
| 154 | + } |
| 155 | + |
| 156 | + /** |
| 157 | + * Set the tags property: List of key-value tag attributes associated with the document model. |
| 158 | + * |
| 159 | + * @param tags the tags value to set. |
| 160 | + * @return the ComposeDocumentModelOptions object itself. |
| 161 | + */ |
| 162 | + @Generated |
| 163 | + public ComposeDocumentModelOptions setTags(Map<String, String> tags) { |
| 164 | + this.tags = tags; |
| 165 | + return this; |
| 166 | + } |
| 167 | + |
| 168 | + /** |
| 169 | + * {@inheritDoc} |
| 170 | + */ |
| 171 | + @Generated |
| 172 | + @Override |
| 173 | + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { |
| 174 | + jsonWriter.writeStartObject(); |
| 175 | + jsonWriter.writeStringField("modelId", this.modelId); |
| 176 | + jsonWriter.writeStringField("classifierId", this.classifierId); |
| 177 | + jsonWriter.writeMapField("docTypes", this.documentTypes, (writer, element) -> writer.writeJson(element)); |
| 178 | + jsonWriter.writeStringField("description", this.description); |
| 179 | + jsonWriter.writeStringField("split", this.split == null ? null : this.split.toString()); |
| 180 | + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); |
| 181 | + return jsonWriter.writeEndObject(); |
| 182 | + } |
| 183 | + |
| 184 | + /** |
| 185 | + * Reads an instance of ComposeDocumentModelOptions from the JsonReader. |
| 186 | + * |
| 187 | + * @param jsonReader The JsonReader being read. |
| 188 | + * @return An instance of ComposeDocumentModelOptions if the JsonReader was pointing to an instance of it, or null |
| 189 | + * if it was pointing to JSON null. |
| 190 | + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. |
| 191 | + * @throws IOException If an error occurs while reading the ComposeDocumentModelOptions. |
| 192 | + */ |
| 193 | + @Generated |
| 194 | + public static ComposeDocumentModelOptions fromJson(JsonReader jsonReader) throws IOException { |
| 195 | + return jsonReader.readObject(reader -> { |
| 196 | + String modelId = null; |
| 197 | + String classifierId = null; |
| 198 | + Map<String, DocumentTypeDetails> documentTypes = null; |
| 199 | + String description = null; |
| 200 | + SplitMode split = null; |
| 201 | + Map<String, String> tags = null; |
| 202 | + while (reader.nextToken() != JsonToken.END_OBJECT) { |
| 203 | + String fieldName = reader.getFieldName(); |
| 204 | + reader.nextToken(); |
| 205 | + |
| 206 | + if ("modelId".equals(fieldName)) { |
| 207 | + modelId = reader.getString(); |
| 208 | + } else if ("classifierId".equals(fieldName)) { |
| 209 | + classifierId = reader.getString(); |
| 210 | + } else if ("docTypes".equals(fieldName)) { |
| 211 | + documentTypes = reader.readMap(reader1 -> DocumentTypeDetails.fromJson(reader1)); |
| 212 | + } else if ("description".equals(fieldName)) { |
| 213 | + description = reader.getString(); |
| 214 | + } else if ("split".equals(fieldName)) { |
| 215 | + split = SplitMode.fromString(reader.getString()); |
| 216 | + } else if ("tags".equals(fieldName)) { |
| 217 | + tags = reader.readMap(reader1 -> reader1.getString()); |
| 218 | + } else { |
| 219 | + reader.skipChildren(); |
| 220 | + } |
| 221 | + } |
| 222 | + ComposeDocumentModelOptions deserializedComposeDocumentModelOptions |
| 223 | + = new ComposeDocumentModelOptions(modelId, classifierId, documentTypes); |
| 224 | + deserializedComposeDocumentModelOptions.description = description; |
| 225 | + deserializedComposeDocumentModelOptions.split = split; |
| 226 | + deserializedComposeDocumentModelOptions.tags = tags; |
| 227 | + |
| 228 | + return deserializedComposeDocumentModelOptions; |
| 229 | + }); |
| 230 | + } |
| 231 | +} |
0 commit comments