-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: pieper <[email protected]>
- Loading branch information
1 parent
64dd87f
commit 7824a97
Showing
4 changed files
with
257 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
201 changes: 201 additions & 0 deletions
201
java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CjkAnalyzer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
package org.opensearch.client.opensearch._types.analysis; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import org.opensearch.client.json.JsonpDeserializable; | ||
import org.opensearch.client.json.JsonpDeserializer; | ||
import org.opensearch.client.json.JsonpMapper; | ||
import org.opensearch.client.json.JsonpSerializable; | ||
import org.opensearch.client.json.ObjectBuilderDeserializer; | ||
import org.opensearch.client.json.ObjectDeserializer; | ||
import org.opensearch.client.util.ApiTypeHelper; | ||
import org.opensearch.client.util.ObjectBuilder; | ||
import org.opensearch.client.util.ObjectBuilderBase; | ||
|
||
import jakarta.json.stream.JsonGenerator; | ||
|
||
// typedef: _types.analysis.LanguageAnalyzer | ||
|
||
@JsonpDeserializable | ||
public class CjkAnalyzer implements AnalyzerVariant, JsonpSerializable { | ||
@Nullable | ||
private final List<String> stopwords; | ||
|
||
@Nullable | ||
private final String stopwordsPath; | ||
|
||
// --------------------------------------------------------------------------------------------- | ||
|
||
private CjkAnalyzer(Builder builder) { | ||
|
||
this.stopwords = ApiTypeHelper.unmodifiable(builder.stopwords); | ||
this.stopwordsPath = builder.stopwordsPath; | ||
|
||
} | ||
|
||
public static CjkAnalyzer of(Function<Builder, ObjectBuilder<CjkAnalyzer>> fn) { | ||
return fn.apply(new Builder()).build(); | ||
} | ||
|
||
/** | ||
* Analyzer variant kind. | ||
*/ | ||
@Override | ||
public Analyzer.Kind _analyzerKind() { | ||
return Analyzer.Kind.Cjk; | ||
} | ||
|
||
/** | ||
* API name: {@code stopwords} | ||
*/ | ||
public final List<String> stopwords() { | ||
return this.stopwords; | ||
} | ||
|
||
/** | ||
* API name: {@code stopwords_path} | ||
*/ | ||
@Nullable | ||
public final String stopwordsPath() { | ||
return this.stopwordsPath; | ||
} | ||
|
||
/** | ||
* Serialize this object to JSON. | ||
*/ | ||
public void serialize(JsonGenerator generator, JsonpMapper mapper) { | ||
generator.writeStartObject(); | ||
serializeInternal(generator, mapper); | ||
generator.writeEnd(); | ||
} | ||
|
||
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { | ||
|
||
generator.write("type", Analyzer.Kind.Cjk.jsonValue()); | ||
|
||
|
||
if (ApiTypeHelper.isDefined(this.stopwords)) { | ||
generator.writeKey("stopwords"); | ||
generator.writeStartArray(); | ||
for (String item0 : this.stopwords) { | ||
generator.write(item0); | ||
|
||
} | ||
generator.writeEnd(); | ||
|
||
} | ||
if (this.stopwordsPath != null) { | ||
generator.writeKey("stopwords_path"); | ||
generator.write(this.stopwordsPath); | ||
|
||
} | ||
|
||
} | ||
|
||
// --------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
* Builder for {@link CjkAnalyzer}. | ||
*/ | ||
|
||
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<CjkAnalyzer> { | ||
@Nullable | ||
private List<String> stopwords; | ||
|
||
@Nullable | ||
private String stopwordsPath; | ||
|
||
/** | ||
* API name: {@code stopwords} | ||
* <p> | ||
* Adds all elements of <code>list</code> to <code>stopwords</code>. | ||
*/ | ||
public final Builder stopwords(List<String> list) { | ||
this.stopwords = _listAddAll(this.stopwords, list); | ||
return this; | ||
} | ||
|
||
/** | ||
* API name: {@code stopwords} | ||
* <p> | ||
* Adds one or more values to <code>stopwords</code>. | ||
*/ | ||
public final Builder stopwords(String value, String... values) { | ||
this.stopwords = _listAdd(this.stopwords, value, values); | ||
return this; | ||
} | ||
|
||
/** | ||
* API name: {@code stopwords_path} | ||
*/ | ||
public final Builder stopwordsPath(@Nullable String value) { | ||
this.stopwordsPath = value; | ||
return this; | ||
} | ||
|
||
/** | ||
* Builds a {@link CjkAnalyzer}. | ||
* | ||
* @throws NullPointerException | ||
* if some required fields are null. | ||
*/ | ||
public CjkAnalyzer build() { | ||
_checkSingleUse(); | ||
|
||
return new CjkAnalyzer(this); | ||
} | ||
} | ||
|
||
// --------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
* Json deserializer for {@link CjkAnalyzer} | ||
*/ | ||
public static final JsonpDeserializer<CjkAnalyzer> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, | ||
CjkAnalyzer::setupLanguageAnalyzerDeserializer); | ||
|
||
protected static void setupLanguageAnalyzerDeserializer(ObjectDeserializer<CjkAnalyzer.Builder> op) { | ||
|
||
op.add(Builder::stopwords, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), | ||
"stopwords"); | ||
op.add(Builder::stopwordsPath, JsonpDeserializer.stringDeserializer(), "stopwords_path"); | ||
|
||
op.ignore("type"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters