|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package co.elastic.clients.elasticsearch._types.analysis; |
| 21 | + |
| 22 | +import co.elastic.clients.json.JsonpDeserializable; |
| 23 | +import co.elastic.clients.json.JsonpDeserializer; |
| 24 | +import co.elastic.clients.json.JsonpMapper; |
| 25 | +import co.elastic.clients.json.ObjectBuilderDeserializer; |
| 26 | +import co.elastic.clients.json.ObjectDeserializer; |
| 27 | +import co.elastic.clients.util.ObjectBuilder; |
| 28 | +import jakarta.json.stream.JsonGenerator; |
| 29 | +import java.lang.Integer; |
| 30 | +import java.util.Objects; |
| 31 | +import java.util.function.Function; |
| 32 | +import javax.annotation.Nullable; |
| 33 | + |
| 34 | +//---------------------------------------------------------------- |
| 35 | +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. |
| 36 | +//---------------------------------------------------------------- |
| 37 | +// |
| 38 | +// This code is generated from the Elasticsearch API specification |
| 39 | +// at https://github.com/elastic/elasticsearch-specification |
| 40 | +// |
| 41 | +// Manual updates to this file will be lost when the code is |
| 42 | +// re-generated. |
| 43 | +// |
| 44 | +// If you find a property that is missing or wrongly typed, please |
| 45 | +// open an issue or a PR on the API specification repository. |
| 46 | +// |
| 47 | +//---------------------------------------------------------------- |
| 48 | + |
| 49 | +// typedef: _types.analysis.ClassicTokenizer |
| 50 | + |
| 51 | +/** |
| 52 | + * |
| 53 | + * @see <a href= |
| 54 | + * "../../doc-files/api-spec.html#_types.analysis.ClassicTokenizer">API |
| 55 | + * specification</a> |
| 56 | + */ |
| 57 | +@JsonpDeserializable |
| 58 | +public class ClassicTokenizer extends TokenizerBase implements TokenizerDefinitionVariant { |
| 59 | + @Nullable |
| 60 | + private final Integer maxTokenLength; |
| 61 | + |
| 62 | + // --------------------------------------------------------------------------------------------- |
| 63 | + |
| 64 | + private ClassicTokenizer(Builder builder) { |
| 65 | + super(builder); |
| 66 | + |
| 67 | + this.maxTokenLength = builder.maxTokenLength; |
| 68 | + |
| 69 | + } |
| 70 | + |
| 71 | + public static ClassicTokenizer of(Function<Builder, ObjectBuilder<ClassicTokenizer>> fn) { |
| 72 | + return fn.apply(new Builder()).build(); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * TokenizerDefinition variant kind. |
| 77 | + */ |
| 78 | + @Override |
| 79 | + public TokenizerDefinition.Kind _tokenizerDefinitionKind() { |
| 80 | + return TokenizerDefinition.Kind.Classic; |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * API name: {@code max_token_length} |
| 85 | + */ |
| 86 | + @Nullable |
| 87 | + public final Integer maxTokenLength() { |
| 88 | + return this.maxTokenLength; |
| 89 | + } |
| 90 | + |
| 91 | + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { |
| 92 | + |
| 93 | + generator.write("type", "classic"); |
| 94 | + super.serializeInternal(generator, mapper); |
| 95 | + if (this.maxTokenLength != null) { |
| 96 | + generator.writeKey("max_token_length"); |
| 97 | + generator.write(this.maxTokenLength); |
| 98 | + |
| 99 | + } |
| 100 | + |
| 101 | + } |
| 102 | + |
| 103 | + // --------------------------------------------------------------------------------------------- |
| 104 | + |
| 105 | + /** |
| 106 | + * Builder for {@link ClassicTokenizer}. |
| 107 | + */ |
| 108 | + |
| 109 | + public static class Builder extends TokenizerBase.AbstractBuilder<Builder> |
| 110 | + implements |
| 111 | + ObjectBuilder<ClassicTokenizer> { |
| 112 | + @Nullable |
| 113 | + private Integer maxTokenLength; |
| 114 | + |
| 115 | + /** |
| 116 | + * API name: {@code max_token_length} |
| 117 | + */ |
| 118 | + public final Builder maxTokenLength(@Nullable Integer value) { |
| 119 | + this.maxTokenLength = value; |
| 120 | + return this; |
| 121 | + } |
| 122 | + |
| 123 | + @Override |
| 124 | + protected Builder self() { |
| 125 | + return this; |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Builds a {@link ClassicTokenizer}. |
| 130 | + * |
| 131 | + * @throws NullPointerException |
| 132 | + * if some of the required fields are null. |
| 133 | + */ |
| 134 | + public ClassicTokenizer build() { |
| 135 | + _checkSingleUse(); |
| 136 | + |
| 137 | + return new ClassicTokenizer(this); |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + // --------------------------------------------------------------------------------------------- |
| 142 | + |
| 143 | + /** |
| 144 | + * Json deserializer for {@link ClassicTokenizer} |
| 145 | + */ |
| 146 | + public static final JsonpDeserializer<ClassicTokenizer> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, |
| 147 | + ClassicTokenizer::setupClassicTokenizerDeserializer); |
| 148 | + |
| 149 | + protected static void setupClassicTokenizerDeserializer(ObjectDeserializer<ClassicTokenizer.Builder> op) { |
| 150 | + TokenizerBase.setupTokenizerBaseDeserializer(op); |
| 151 | + op.add(Builder::maxTokenLength, JsonpDeserializer.integerDeserializer(), "max_token_length"); |
| 152 | + |
| 153 | + op.ignore("type"); |
| 154 | + } |
| 155 | + |
| 156 | +} |
0 commit comments