< Summary

Class:Azure.Search.Documents.Indexes.Models.KeywordTokenizer
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\KeywordTokenizer.cs
Covered lines:43
Uncovered lines:0
Coverable lines:43
Total lines:118
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_BufferSize()-100%100%
get_MaxTokenLength()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-100%100%
DeserializeKeywordTokenizer(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\KeywordTokenizer.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("KeywordTokenizerV2")]
 10    [CodeGenSuppress(nameof(KeywordTokenizer), typeof(string), typeof(string), typeof(int?))]
 11    public partial class KeywordTokenizer : IUtf8JsonSerializable
 12    {
 13        /// <summary>
 14        /// Initializes a new instance of KeywordTokenizer.
 15        /// </summary>
 16        /// <param name="name">
 17        /// The name of the tokenizer. It must only contain letters, digits, spaces,
 18        /// dashes or underscores, can only start and end with alphanumeric characters,
 19        /// and is limited to 128 characters.
 20        /// </param>
 321        public KeywordTokenizer(string name) : base(name)
 22        {
 323            Argument.AssertNotNull(name, nameof(name));
 24
 325            ODataType = "#Microsoft.Azure.Search.KeywordTokenizerV2";
 326        }
 27
 28        /// <summary>
 29        /// The read buffer size in bytes. Default is 256.
 30        /// Setting this property on new instances of <see cref="KeywordTokenizer"/> may result in an error
 31        /// when sending new requests to the Azure Cognitive Search service.
 32        /// </summary>
 833        public int? BufferSize { get; set; }
 34
 35        /// <summary>
 36        /// The maximum token length. Default is 256.
 37        /// Tokens longer than the maximum length are split.
 38        /// The maximum token length that can be used is 300 characters.
 39        /// </summary>
 840        public int? MaxTokenLength { get; set; }
 41
 42        // Use global scope to fully qualify name to work around bug in generator currently.
 43        void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 44        {
 245            writer.WriteStartObject();
 46
 247            writer.WritePropertyName("@odata.type");
 248            writer.WriteStringValue(ODataType);
 49
 250            writer.WritePropertyName("name");
 251            writer.WriteStringValue(Name);
 52
 253            if (BufferSize != null)
 54            {
 255                writer.WritePropertyName("bufferSize");
 256                writer.WriteNumberValue(BufferSize.Value);
 57            }
 58
 259            if (MaxTokenLength != null)
 60            {
 261                writer.WritePropertyName("maxTokenLength");
 262                writer.WriteNumberValue(MaxTokenLength.Value);
 63            }
 64
 265            writer.WriteEndObject();
 266        }
 67
 68        internal static KeywordTokenizer DeserializeKeywordTokenizer(JsonElement element)
 69        {
 270            int? bufferSize = default;
 271            int? maxTokenLength = default;
 272            string odataType = default;
 273            string name = default;
 74
 2075            foreach (JsonProperty property in element.EnumerateObject())
 76            {
 877                if (property.NameEquals("@odata.type"))
 78                {
 279                    odataType = property.Value.GetString();
 280                    continue;
 81                }
 82
 683                if (property.NameEquals("name"))
 84                {
 285                    name = property.Value.GetString();
 286                    continue;
 87                }
 88
 489                if (property.NameEquals("bufferSize"))
 90                {
 291                    if (property.Value.ValueKind == JsonValueKind.Null)
 92                    {
 93                        continue;
 94                    }
 295                    bufferSize = property.Value.GetInt32();
 296                    continue;
 97                }
 98
 299                if (property.NameEquals("maxTokenLength"))
 100                {
 2101                    if (property.Value.ValueKind == JsonValueKind.Null)
 102                    {
 103                        continue;
 104                    }
 2105                    maxTokenLength = property.Value.GetInt32();
 106                    continue;
 107                }
 108            }
 109
 2110            return new KeywordTokenizer(name)
 2111            {
 2112                ODataType = odataType,
 2113                BufferSize = bufferSize,
 2114                MaxTokenLength = maxTokenLength,
 2115            };
 116        }
 117    }
 118}