< Summary

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

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\EdgeNGramTokenFilter.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("EdgeNGramTokenFilterV2")]
 10    [CodeGenSuppress(nameof(EdgeNGramTokenFilter), typeof(string), typeof(string), typeof(int?), typeof(int?), typeof(Ed
 11    public partial class EdgeNGramTokenFilter : IUtf8JsonSerializable
 12    {
 13        /// <summary> Initializes a new instance of EdgeNGramTokenFilter. </summary>
 14        /// <param name="name"> The name of the token filter. It must only contain letters, digits, spaces, dashes or un
 315        public EdgeNGramTokenFilter(string name) : base(name)
 16        {
 317            Argument.AssertNotNull(name, nameof(name));
 18
 319            ODataType = "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2";
 320        }
 21
 22        /// <summary>
 23        /// The minimum n-gram length. Default is 1. Must be less than the value of maxGram.
 24        /// </summary>
 825        public int? MinGram { get; set; }
 26
 27        /// <summary>
 28        /// The maximum n-gram length. Default is 2.
 29        /// </summary>
 830        public int? MaxGram { get; set; }
 31
 32        /// <summary>
 33        /// Specifies which side of the input the n-gram should be generated from. Default is <see cref="EdgeNGramTokenF
 34        /// </summary>
 835        public EdgeNGramTokenFilterSide? Side { get; set; }
 36
 37        void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 38        {
 239            writer.WriteStartObject();
 40
 241            writer.WritePropertyName("@odata.type");
 242            writer.WriteStringValue(ODataType);
 43
 244            writer.WritePropertyName("name");
 245            writer.WriteStringValue(Name);
 46
 247            if (MinGram != null)
 48            {
 249                writer.WritePropertyName("minGram");
 250                writer.WriteNumberValue(MinGram.Value);
 51            }
 52
 253            if (MaxGram != null)
 54            {
 255                writer.WritePropertyName("maxGram");
 256                writer.WriteNumberValue(MaxGram.Value);
 57            }
 58
 259            if (Side != null)
 60            {
 261                writer.WritePropertyName("side");
 262                writer.WriteStringValue(Side.Value.ToSerialString());
 63            }
 64
 265            writer.WriteEndObject();
 266        }
 67
 68        internal static EdgeNGramTokenFilter DeserializeEdgeNGramTokenFilter(JsonElement element)
 69        {
 270            int? minGram = default;
 271            int? maxGram = default;
 272            EdgeNGramTokenFilterSide? side = default;
 273            string odataType = default;
 274            string name = default;
 75
 2476            foreach (var property in element.EnumerateObject())
 77            {
 1078                if (property.NameEquals("@odata.type"))
 79                {
 280                    odataType = property.Value.GetString();
 281                    continue;
 82                }
 83
 884                if (property.NameEquals("name"))
 85                {
 286                    name = property.Value.GetString();
 287                    continue;
 88                }
 89
 690                if (property.NameEquals("minGram"))
 91                {
 292                    if (property.Value.ValueKind == JsonValueKind.Null)
 93                    {
 94                        continue;
 95                    }
 296                    minGram = property.Value.GetInt32();
 297                    continue;
 98                }
 99
 4100                if (property.NameEquals("maxGram"))
 101                {
 2102                    if (property.Value.ValueKind == JsonValueKind.Null)
 103                    {
 104                        continue;
 105                    }
 2106                    maxGram = property.Value.GetInt32();
 2107                    continue;
 108                }
 109
 2110                if (property.NameEquals("side"))
 111                {
 2112                    if (property.Value.ValueKind == JsonValueKind.Null)
 113                    {
 114                        continue;
 115                    }
 2116                    side = property.Value.GetString().ToEdgeNGramTokenFilterSide();
 117                    continue;
 118                }
 119            }
 120
 2121            return new EdgeNGramTokenFilter(name)
 2122            {
 2123                ODataType = odataType,
 2124                MinGram = minGram,
 2125                MaxGram = maxGram,
 2126                Side = side,
 2127            };
 128        }
 129    }
 130}