| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.Search.Documents.Indexes.Models |
| | 12 | | { |
| | 13 | | public partial class PathHierarchyTokenizer : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 1 | 17 | | writer.WriteStartObject(); |
| 1 | 18 | | if (Optional.IsDefined(Delimiter)) |
| | 19 | | { |
| 1 | 20 | | writer.WritePropertyName("delimiter"); |
| 1 | 21 | | writer.WriteStringValue(Delimiter.Value); |
| | 22 | | } |
| 1 | 23 | | if (Optional.IsDefined(Replacement)) |
| | 24 | | { |
| 1 | 25 | | writer.WritePropertyName("replacement"); |
| 1 | 26 | | writer.WriteStringValue(Replacement.Value); |
| | 27 | | } |
| 1 | 28 | | if (Optional.IsDefined(MaxTokenLength)) |
| | 29 | | { |
| 1 | 30 | | writer.WritePropertyName("maxTokenLength"); |
| 1 | 31 | | writer.WriteNumberValue(MaxTokenLength.Value); |
| | 32 | | } |
| 1 | 33 | | if (Optional.IsDefined(ReverseTokenOrder)) |
| | 34 | | { |
| 1 | 35 | | writer.WritePropertyName("reverse"); |
| 1 | 36 | | writer.WriteBooleanValue(ReverseTokenOrder.Value); |
| | 37 | | } |
| 1 | 38 | | if (Optional.IsDefined(NumberOfTokensToSkip)) |
| | 39 | | { |
| 1 | 40 | | writer.WritePropertyName("skip"); |
| 1 | 41 | | writer.WriteNumberValue(NumberOfTokensToSkip.Value); |
| | 42 | | } |
| 1 | 43 | | writer.WritePropertyName("@odata.type"); |
| 1 | 44 | | writer.WriteStringValue(ODataType); |
| 1 | 45 | | writer.WritePropertyName("name"); |
| 1 | 46 | | writer.WriteStringValue(Name); |
| 1 | 47 | | writer.WriteEndObject(); |
| 1 | 48 | | } |
| | 49 | |
|
| | 50 | | internal static PathHierarchyTokenizer DeserializePathHierarchyTokenizer(JsonElement element) |
| | 51 | | { |
| 1 | 52 | | Optional<char> delimiter = default; |
| 1 | 53 | | Optional<char> replacement = default; |
| 1 | 54 | | Optional<int> maxTokenLength = default; |
| 1 | 55 | | Optional<bool> reverse = default; |
| 1 | 56 | | Optional<int> skip = default; |
| 1 | 57 | | string odataType = default; |
| 1 | 58 | | string name = default; |
| 16 | 59 | | foreach (var property in element.EnumerateObject()) |
| | 60 | | { |
| 7 | 61 | | if (property.NameEquals("delimiter")) |
| | 62 | | { |
| 1 | 63 | | delimiter = property.Value.GetChar(); |
| 1 | 64 | | continue; |
| | 65 | | } |
| 6 | 66 | | if (property.NameEquals("replacement")) |
| | 67 | | { |
| 1 | 68 | | replacement = property.Value.GetChar(); |
| 1 | 69 | | continue; |
| | 70 | | } |
| 5 | 71 | | if (property.NameEquals("maxTokenLength")) |
| | 72 | | { |
| 1 | 73 | | maxTokenLength = property.Value.GetInt32(); |
| 1 | 74 | | continue; |
| | 75 | | } |
| 4 | 76 | | if (property.NameEquals("reverse")) |
| | 77 | | { |
| 1 | 78 | | reverse = property.Value.GetBoolean(); |
| 1 | 79 | | continue; |
| | 80 | | } |
| 3 | 81 | | if (property.NameEquals("skip")) |
| | 82 | | { |
| 1 | 83 | | skip = property.Value.GetInt32(); |
| 1 | 84 | | continue; |
| | 85 | | } |
| 2 | 86 | | if (property.NameEquals("@odata.type")) |
| | 87 | | { |
| 1 | 88 | | odataType = property.Value.GetString(); |
| 1 | 89 | | continue; |
| | 90 | | } |
| 1 | 91 | | if (property.NameEquals("name")) |
| | 92 | | { |
| 1 | 93 | | name = property.Value.GetString(); |
| | 94 | | continue; |
| | 95 | | } |
| | 96 | | } |
| 1 | 97 | | return new PathHierarchyTokenizer(odataType, name, Optional.ToNullable(delimiter), Optional.ToNullable(repla |
| | 98 | | } |
| | 99 | | } |
| | 100 | | } |