< Summary

Class:Azure.Search.Documents.Indexes.Models.NGramTokenFilter
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\NGramTokenFilter.cs
Covered lines:43
Uncovered lines:0
Coverable lines:43
Total lines:114
Line coverage:100% (43 of 43)
Covered branches:18
Total branches:18
Branch coverage:100% (18 of 18)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_MinGram()-100%100%
get_MaxGram()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-100%100%
DeserializeNGramTokenFilter(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\NGramTokenFilter.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Text.Json;
 5using Azure.Core;
 6
 7namespace Azure.Search.Documents.Indexes.Models
 8{
 9    [CodeGenModel("NGramTokenFilterV2")]
 10    [CodeGenSuppress(nameof(NGramTokenFilter), typeof(string), typeof(string), typeof(int?), typeof(int?))]
 11    public partial class NGramTokenFilter : IUtf8JsonSerializable
 12    {
 13        /// <summary>
 14        /// Initializes a new instance of NGramTokenFilter.
 15        /// </summary>
 16        /// <param name="name">
 17        /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores,
 18        /// can only start and end with alphanumeric characters, and is limited to 128 characters.
 19        /// </param>
 320        public NGramTokenFilter(string name) : base(name)
 21        {
 322            Argument.AssertNotNull(name, nameof(name));
 23
 324            ODataType = "#Microsoft.Azure.Search.NGramTokenFilterV2";
 325        }
 26
 27        /// <summary>
 28        /// The minimum n-gram length. Default is 1.
 29        /// Maximum is 300.
 30        /// Must be less than the value of maxGram.
 31        /// </summary>
 832        public int? MinGram { get; set; }
 33
 34        /// <summary>
 35        /// The maximum n-gram length. Default is 2.
 36        /// Maximum is 300.
 37        /// </summary>
 838        public int? MaxGram { get; set; }
 39
 40        void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 41        {
 242            writer.WriteStartObject();
 43
 244            writer.WritePropertyName("@odata.type");
 245            writer.WriteStringValue(ODataType);
 46
 247            writer.WritePropertyName("name");
 248            writer.WriteStringValue(Name);
 49
 250            if (MinGram != null)
 51            {
 252                writer.WritePropertyName("minGram");
 253                writer.WriteNumberValue(MinGram.Value);
 54            }
 55
 256            if (MaxGram != null)
 57            {
 258                writer.WritePropertyName("maxGram");
 259                writer.WriteNumberValue(MaxGram.Value);
 60            }
 61
 262            writer.WriteEndObject();
 263        }
 64
 65        internal static NGramTokenFilter DeserializeNGramTokenFilter(JsonElement element)
 66        {
 267            int? minGram = default;
 268            int? maxGram = default;
 269            string odataType = default;
 270            string name = default;
 2071            foreach (var property in element.EnumerateObject())
 72            {
 873                if (property.NameEquals("@odata.type"))
 74                {
 275                    odataType = property.Value.GetString();
 276                    continue;
 77                }
 78
 679                if (property.NameEquals("name"))
 80                {
 281                    name = property.Value.GetString();
 282                    continue;
 83                }
 84
 485                if (property.NameEquals("minGram"))
 86                {
 287                    if (property.Value.ValueKind == JsonValueKind.Null)
 88                    {
 89                        continue;
 90                    }
 291                    minGram = property.Value.GetInt32();
 292                    continue;
 93                }
 94
 295                if (property.NameEquals("maxGram"))
 96                {
 297                    if (property.Value.ValueKind == JsonValueKind.Null)
 98                    {
 99                        continue;
 100                    }
 2101                    maxGram = property.Value.GetInt32();
 102                    continue;
 103                }
 104            }
 105
 2106            return new NGramTokenFilter(name)
 2107            {
 2108                ODataType = odataType,
 2109                MinGram = minGram,
 2110                MaxGram = maxGram,
 2111            };
 112        }
 113    }
 114}