|
| 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 tsptest.errormodel.models; |
| 6 | + |
| 7 | +import com.azure.core.annotation.Generated; |
| 8 | +import com.azure.core.annotation.Immutable; |
| 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 | + |
| 15 | +/** |
| 16 | + * An object containing more specific information about the error. As per Microsoft One API guidelines - |
| 17 | + * https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. |
| 18 | + */ |
| 19 | +@Immutable |
| 20 | +public final class InnerError implements JsonSerializable<InnerError> { |
| 21 | + /* |
| 22 | + * One of a server-defined set of error codes. |
| 23 | + */ |
| 24 | + @Generated |
| 25 | + private String code; |
| 26 | + |
| 27 | + /* |
| 28 | + * Inner error. |
| 29 | + */ |
| 30 | + @Generated |
| 31 | + private InnerError innerError; |
| 32 | + |
| 33 | + /** |
| 34 | + * Creates an instance of InnerError class. |
| 35 | + */ |
| 36 | + @Generated |
| 37 | + private InnerError() { |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Get the code property: One of a server-defined set of error codes. |
| 42 | + * |
| 43 | + * @return the code value. |
| 44 | + */ |
| 45 | + @Generated |
| 46 | + public String getCode() { |
| 47 | + return this.code; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Get the innerError property: Inner error. |
| 52 | + * |
| 53 | + * @return the innerError value. |
| 54 | + */ |
| 55 | + @Generated |
| 56 | + public InnerError getInnerError() { |
| 57 | + return this.innerError; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * {@inheritDoc} |
| 62 | + */ |
| 63 | + @Generated |
| 64 | + @Override |
| 65 | + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { |
| 66 | + jsonWriter.writeStartObject(); |
| 67 | + jsonWriter.writeStringField("code", this.code); |
| 68 | + jsonWriter.writeJsonField("innererror", this.innerError); |
| 69 | + return jsonWriter.writeEndObject(); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Reads an instance of InnerError from the JsonReader. |
| 74 | + * |
| 75 | + * @param jsonReader The JsonReader being read. |
| 76 | + * @return An instance of InnerError if the JsonReader was pointing to an instance of it, or null if it was pointing |
| 77 | + * to JSON null. |
| 78 | + * @throws IOException If an error occurs while reading the InnerError. |
| 79 | + */ |
| 80 | + @Generated |
| 81 | + public static InnerError fromJson(JsonReader jsonReader) throws IOException { |
| 82 | + return jsonReader.readObject(reader -> { |
| 83 | + InnerError deserializedInnerError = new InnerError(); |
| 84 | + while (reader.nextToken() != JsonToken.END_OBJECT) { |
| 85 | + String fieldName = reader.getFieldName(); |
| 86 | + reader.nextToken(); |
| 87 | + |
| 88 | + if ("code".equals(fieldName)) { |
| 89 | + deserializedInnerError.code = reader.getString(); |
| 90 | + } else if ("innererror".equals(fieldName)) { |
| 91 | + deserializedInnerError.innerError = InnerError.fromJson(reader); |
| 92 | + } else { |
| 93 | + reader.skipChildren(); |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + return deserializedInnerError; |
| 98 | + }); |
| 99 | + } |
| 100 | +} |
0 commit comments