| | 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.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.Search.Documents.Indexes.Models |
| | 13 | | { |
| | 14 | | public partial class PatternAnalyzer : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 5 | 18 | | writer.WriteStartObject(); |
| 5 | 19 | | if (Optional.IsDefined(LowerCaseTerms)) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("lowercase"); |
| 0 | 22 | | writer.WriteBooleanValue(LowerCaseTerms.Value); |
| | 23 | | } |
| 5 | 24 | | if (Optional.IsDefined(Pattern)) |
| | 25 | | { |
| 2 | 26 | | writer.WritePropertyName("pattern"); |
| 2 | 27 | | writer.WriteStringValue(Pattern); |
| | 28 | | } |
| 5 | 29 | | if (Optional.IsDefined(FlagsInternal)) |
| | 30 | | { |
| 5 | 31 | | writer.WritePropertyName("flags"); |
| 5 | 32 | | writer.WriteStringValue(FlagsInternal); |
| | 33 | | } |
| 5 | 34 | | if (Optional.IsCollectionDefined(Stopwords)) |
| | 35 | | { |
| 2 | 36 | | writer.WritePropertyName("stopwords"); |
| 2 | 37 | | writer.WriteStartArray(); |
| 16 | 38 | | foreach (var item in Stopwords) |
| | 39 | | { |
| 6 | 40 | | writer.WriteStringValue(item); |
| | 41 | | } |
| 2 | 42 | | writer.WriteEndArray(); |
| | 43 | | } |
| 5 | 44 | | writer.WritePropertyName("@odata.type"); |
| 5 | 45 | | writer.WriteStringValue(ODataType); |
| 5 | 46 | | writer.WritePropertyName("name"); |
| 5 | 47 | | writer.WriteStringValue(Name); |
| 5 | 48 | | writer.WriteEndObject(); |
| 5 | 49 | | } |
| | 50 | |
|
| | 51 | | internal static PatternAnalyzer DeserializePatternAnalyzer(JsonElement element) |
| | 52 | | { |
| 5 | 53 | | Optional<bool> lowercase = default; |
| 5 | 54 | | Optional<string> pattern = default; |
| 5 | 55 | | Optional<string> flags = default; |
| 5 | 56 | | Optional<IList<string>> stopwords = default; |
| 5 | 57 | | string odataType = default; |
| 5 | 58 | | string name = default; |
| 52 | 59 | | foreach (var property in element.EnumerateObject()) |
| | 60 | | { |
| 21 | 61 | | if (property.NameEquals("lowercase")) |
| | 62 | | { |
| 2 | 63 | | lowercase = property.Value.GetBoolean(); |
| 2 | 64 | | continue; |
| | 65 | | } |
| 19 | 66 | | if (property.NameEquals("pattern")) |
| | 67 | | { |
| 2 | 68 | | pattern = property.Value.GetString(); |
| 2 | 69 | | continue; |
| | 70 | | } |
| 17 | 71 | | if (property.NameEquals("flags")) |
| | 72 | | { |
| 5 | 73 | | flags = property.Value.GetString(); |
| 5 | 74 | | continue; |
| | 75 | | } |
| 12 | 76 | | if (property.NameEquals("stopwords")) |
| | 77 | | { |
| 2 | 78 | | List<string> array = new List<string>(); |
| 16 | 79 | | foreach (var item in property.Value.EnumerateArray()) |
| | 80 | | { |
| 6 | 81 | | array.Add(item.GetString()); |
| | 82 | | } |
| 2 | 83 | | stopwords = array; |
| 2 | 84 | | continue; |
| | 85 | | } |
| 10 | 86 | | if (property.NameEquals("@odata.type")) |
| | 87 | | { |
| 5 | 88 | | odataType = property.Value.GetString(); |
| 5 | 89 | | continue; |
| | 90 | | } |
| 5 | 91 | | if (property.NameEquals("name")) |
| | 92 | | { |
| 5 | 93 | | name = property.Value.GetString(); |
| | 94 | | continue; |
| | 95 | | } |
| | 96 | | } |
| 5 | 97 | | return new PatternAnalyzer(odataType, name, Optional.ToNullable(lowercase), pattern.Value, flags.Value, Opti |
| | 98 | | } |
| | 99 | | } |
| | 100 | | } |