|
| 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.JsonpSerializable; |
| 26 | +import co.elastic.clients.json.JsonpUtils; |
| 27 | +import co.elastic.clients.json.ObjectBuilderDeserializer; |
| 28 | +import co.elastic.clients.json.ObjectDeserializer; |
| 29 | +import co.elastic.clients.util.ApiTypeHelper; |
| 30 | +import co.elastic.clients.util.ObjectBuilder; |
| 31 | +import co.elastic.clients.util.WithJsonObjectBuilderBase; |
| 32 | +import jakarta.json.stream.JsonGenerator; |
| 33 | +import java.lang.String; |
| 34 | +import java.util.List; |
| 35 | +import java.util.Objects; |
| 36 | +import java.util.function.Function; |
| 37 | +import javax.annotation.Nullable; |
| 38 | + |
| 39 | +//---------------------------------------------------------------- |
| 40 | +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. |
| 41 | +//---------------------------------------------------------------- |
| 42 | +// |
| 43 | +// This code is generated from the Elasticsearch API specification |
| 44 | +// at https://github.com/elastic/elasticsearch-specification |
| 45 | +// |
| 46 | +// Manual updates to this file will be lost when the code is |
| 47 | +// re-generated. |
| 48 | +// |
| 49 | +// If you find a property that is missing or wrongly typed, please |
| 50 | +// open an issue or a PR on the API specification repository. |
| 51 | +// |
| 52 | +//---------------------------------------------------------------- |
| 53 | + |
| 54 | +// typedef: _types.analysis.ArabicAnalyzer |
| 55 | + |
| 56 | +/** |
| 57 | + * |
| 58 | + * @see <a href= |
| 59 | + * "../../doc-files/api-spec.html#_types.analysis.ArabicAnalyzer">API |
| 60 | + * specification</a> |
| 61 | + */ |
| 62 | +@JsonpDeserializable |
| 63 | +public class ArabicAnalyzer implements AnalyzerVariant, JsonpSerializable { |
| 64 | + private final List<String> stopwords; |
| 65 | + |
| 66 | + @Nullable |
| 67 | + private final String stopwordsPath; |
| 68 | + |
| 69 | + private final List<String> stemExclusion; |
| 70 | + |
| 71 | + // --------------------------------------------------------------------------------------------- |
| 72 | + |
| 73 | + private ArabicAnalyzer(Builder builder) { |
| 74 | + |
| 75 | + this.stopwords = ApiTypeHelper.unmodifiable(builder.stopwords); |
| 76 | + this.stopwordsPath = builder.stopwordsPath; |
| 77 | + this.stemExclusion = ApiTypeHelper.unmodifiable(builder.stemExclusion); |
| 78 | + |
| 79 | + } |
| 80 | + |
| 81 | + public static ArabicAnalyzer of(Function<Builder, ObjectBuilder<ArabicAnalyzer>> fn) { |
| 82 | + return fn.apply(new Builder()).build(); |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Analyzer variant kind. |
| 87 | + */ |
| 88 | + @Override |
| 89 | + public Analyzer.Kind _analyzerKind() { |
| 90 | + return Analyzer.Kind.Arabic; |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * API name: {@code stopwords} |
| 95 | + */ |
| 96 | + public final List<String> stopwords() { |
| 97 | + return this.stopwords; |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * API name: {@code stopwords_path} |
| 102 | + */ |
| 103 | + @Nullable |
| 104 | + public final String stopwordsPath() { |
| 105 | + return this.stopwordsPath; |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * API name: {@code stem_exclusion} |
| 110 | + */ |
| 111 | + public final List<String> stemExclusion() { |
| 112 | + return this.stemExclusion; |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Serialize this object to JSON. |
| 117 | + */ |
| 118 | + public void serialize(JsonGenerator generator, JsonpMapper mapper) { |
| 119 | + generator.writeStartObject(); |
| 120 | + serializeInternal(generator, mapper); |
| 121 | + generator.writeEnd(); |
| 122 | + } |
| 123 | + |
| 124 | + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { |
| 125 | + |
| 126 | + generator.write("type", "arabic"); |
| 127 | + |
| 128 | + if (ApiTypeHelper.isDefined(this.stopwords)) { |
| 129 | + generator.writeKey("stopwords"); |
| 130 | + generator.writeStartArray(); |
| 131 | + for (String item0 : this.stopwords) { |
| 132 | + generator.write(item0); |
| 133 | + |
| 134 | + } |
| 135 | + generator.writeEnd(); |
| 136 | + |
| 137 | + } |
| 138 | + if (this.stopwordsPath != null) { |
| 139 | + generator.writeKey("stopwords_path"); |
| 140 | + generator.write(this.stopwordsPath); |
| 141 | + |
| 142 | + } |
| 143 | + if (ApiTypeHelper.isDefined(this.stemExclusion)) { |
| 144 | + generator.writeKey("stem_exclusion"); |
| 145 | + generator.writeStartArray(); |
| 146 | + for (String item0 : this.stemExclusion) { |
| 147 | + generator.write(item0); |
| 148 | + |
| 149 | + } |
| 150 | + generator.writeEnd(); |
| 151 | + |
| 152 | + } |
| 153 | + |
| 154 | + } |
| 155 | + |
| 156 | + @Override |
| 157 | + public String toString() { |
| 158 | + return JsonpUtils.toString(this); |
| 159 | + } |
| 160 | + |
| 161 | + // --------------------------------------------------------------------------------------------- |
| 162 | + |
| 163 | + /** |
| 164 | + * Builder for {@link ArabicAnalyzer}. |
| 165 | + */ |
| 166 | + |
| 167 | + public static class Builder extends WithJsonObjectBuilderBase<Builder> implements ObjectBuilder<ArabicAnalyzer> { |
| 168 | + @Nullable |
| 169 | + private List<String> stopwords; |
| 170 | + |
| 171 | + @Nullable |
| 172 | + private String stopwordsPath; |
| 173 | + |
| 174 | + @Nullable |
| 175 | + private List<String> stemExclusion; |
| 176 | + |
| 177 | + /** |
| 178 | + * API name: {@code stopwords} |
| 179 | + * <p> |
| 180 | + * Adds all elements of <code>list</code> to <code>stopwords</code>. |
| 181 | + */ |
| 182 | + public final Builder stopwords(List<String> list) { |
| 183 | + this.stopwords = _listAddAll(this.stopwords, list); |
| 184 | + return this; |
| 185 | + } |
| 186 | + |
| 187 | + /** |
| 188 | + * API name: {@code stopwords} |
| 189 | + * <p> |
| 190 | + * Adds one or more values to <code>stopwords</code>. |
| 191 | + */ |
| 192 | + public final Builder stopwords(String value, String... values) { |
| 193 | + this.stopwords = _listAdd(this.stopwords, value, values); |
| 194 | + return this; |
| 195 | + } |
| 196 | + |
| 197 | + /** |
| 198 | + * API name: {@code stopwords_path} |
| 199 | + */ |
| 200 | + public final Builder stopwordsPath(@Nullable String value) { |
| 201 | + this.stopwordsPath = value; |
| 202 | + return this; |
| 203 | + } |
| 204 | + |
| 205 | + /** |
| 206 | + * API name: {@code stem_exclusion} |
| 207 | + * <p> |
| 208 | + * Adds all elements of <code>list</code> to <code>stemExclusion</code>. |
| 209 | + */ |
| 210 | + public final Builder stemExclusion(List<String> list) { |
| 211 | + this.stemExclusion = _listAddAll(this.stemExclusion, list); |
| 212 | + return this; |
| 213 | + } |
| 214 | + |
| 215 | + /** |
| 216 | + * API name: {@code stem_exclusion} |
| 217 | + * <p> |
| 218 | + * Adds one or more values to <code>stemExclusion</code>. |
| 219 | + */ |
| 220 | + public final Builder stemExclusion(String value, String... values) { |
| 221 | + this.stemExclusion = _listAdd(this.stemExclusion, value, values); |
| 222 | + return this; |
| 223 | + } |
| 224 | + |
| 225 | + @Override |
| 226 | + protected Builder self() { |
| 227 | + return this; |
| 228 | + } |
| 229 | + |
| 230 | + /** |
| 231 | + * Builds a {@link ArabicAnalyzer}. |
| 232 | + * |
| 233 | + * @throws NullPointerException |
| 234 | + * if some of the required fields are null. |
| 235 | + */ |
| 236 | + public ArabicAnalyzer build() { |
| 237 | + _checkSingleUse(); |
| 238 | + |
| 239 | + return new ArabicAnalyzer(this); |
| 240 | + } |
| 241 | + } |
| 242 | + |
| 243 | + // --------------------------------------------------------------------------------------------- |
| 244 | + |
| 245 | + /** |
| 246 | + * Json deserializer for {@link ArabicAnalyzer} |
| 247 | + */ |
| 248 | + public static final JsonpDeserializer<ArabicAnalyzer> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, |
| 249 | + ArabicAnalyzer::setupArabicAnalyzerDeserializer); |
| 250 | + |
| 251 | + protected static void setupArabicAnalyzerDeserializer(ObjectDeserializer<ArabicAnalyzer.Builder> op) { |
| 252 | + |
| 253 | + op.add(Builder::stopwords, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), |
| 254 | + "stopwords"); |
| 255 | + op.add(Builder::stopwordsPath, JsonpDeserializer.stringDeserializer(), "stopwords_path"); |
| 256 | + op.add(Builder::stemExclusion, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), |
| 257 | + "stem_exclusion"); |
| 258 | + |
| 259 | + op.ignore("type"); |
| 260 | + } |
| 261 | + |
| 262 | +} |
0 commit comments