| | 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 PatternTokenizer : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 3 | 17 | | writer.WriteStartObject(); |
| 3 | 18 | | if (Optional.IsDefined(Pattern)) |
| | 19 | | { |
| 0 | 20 | | writer.WritePropertyName("pattern"); |
| 0 | 21 | | writer.WriteStringValue(Pattern); |
| | 22 | | } |
| 3 | 23 | | if (Optional.IsDefined(FlagsInternal)) |
| | 24 | | { |
| 3 | 25 | | writer.WritePropertyName("flags"); |
| 3 | 26 | | writer.WriteStringValue(FlagsInternal); |
| | 27 | | } |
| 3 | 28 | | if (Optional.IsDefined(Group)) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("group"); |
| 0 | 31 | | writer.WriteNumberValue(Group.Value); |
| | 32 | | } |
| 3 | 33 | | writer.WritePropertyName("@odata.type"); |
| 3 | 34 | | writer.WriteStringValue(ODataType); |
| 3 | 35 | | writer.WritePropertyName("name"); |
| 3 | 36 | | writer.WriteStringValue(Name); |
| 3 | 37 | | writer.WriteEndObject(); |
| 3 | 38 | | } |
| | 39 | |
|
| | 40 | | internal static PatternTokenizer DeserializePatternTokenizer(JsonElement element) |
| | 41 | | { |
| 3 | 42 | | Optional<string> pattern = default; |
| 3 | 43 | | Optional<string> flags = default; |
| 3 | 44 | | Optional<int> group = default; |
| 3 | 45 | | string odataType = default; |
| 3 | 46 | | string name = default; |
| 24 | 47 | | foreach (var property in element.EnumerateObject()) |
| | 48 | | { |
| 9 | 49 | | if (property.NameEquals("pattern")) |
| | 50 | | { |
| 0 | 51 | | pattern = property.Value.GetString(); |
| 0 | 52 | | continue; |
| | 53 | | } |
| 9 | 54 | | if (property.NameEquals("flags")) |
| | 55 | | { |
| 3 | 56 | | flags = property.Value.GetString(); |
| 3 | 57 | | continue; |
| | 58 | | } |
| 6 | 59 | | if (property.NameEquals("group")) |
| | 60 | | { |
| 0 | 61 | | group = property.Value.GetInt32(); |
| 0 | 62 | | continue; |
| | 63 | | } |
| 6 | 64 | | if (property.NameEquals("@odata.type")) |
| | 65 | | { |
| 3 | 66 | | odataType = property.Value.GetString(); |
| 3 | 67 | | continue; |
| | 68 | | } |
| 3 | 69 | | if (property.NameEquals("name")) |
| | 70 | | { |
| 3 | 71 | | name = property.Value.GetString(); |
| | 72 | | continue; |
| | 73 | | } |
| | 74 | | } |
| 3 | 75 | | return new PatternTokenizer(odataType, name, pattern.Value, flags.Value, Optional.ToNullable(group)); |
| | 76 | | } |
| | 77 | | } |
| | 78 | | } |