From d55b5062be1267c2e586fe6674303f27e5d0687e Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 12 Nov 2024 12:56:25 +1300 Subject: [PATCH 1/4] Generate TokenFilter variants Signed-off-by: Thomas Farr --- UPGRADING.md | 18 +- .../_types/BuiltinScriptLanguage.java | 69 +++ .../opensearch/_types/InlineScript.java | 85 ++- .../client/opensearch/_types/Script.java | 44 +- .../client/opensearch/_types/ScriptBase.java | 54 +- .../opensearch/_types/ScriptBuilders.java | 11 +- .../opensearch/_types/ScriptLanguage.java | 200 +++++++ .../opensearch/_types/StoredScriptId.java | 38 +- .../analysis/AsciiFoldingTokenFilter.java | 62 +- .../analysis/CommonGramsTokenFilter.java | 63 ++- .../analysis/CompoundWordTokenFilterBase.java | 72 ++- .../_types/analysis/ConditionTokenFilter.java | 66 ++- .../analysis/DelimitedPayloadEncoding.java | 12 +- .../analysis/DelimitedPayloadTokenFilter.java | 77 ++- .../DictionaryDecompounderTokenFilter.java | 36 +- .../_types/analysis/EdgeNGramSide.java | 12 +- .../_types/analysis/EdgeNGramTokenFilter.java | 131 +++-- .../_types/analysis/ElisionTokenFilter.java | 107 +++- .../analysis/FingerprintTokenFilter.java | 79 ++- .../_types/analysis/HunspellTokenFilter.java | 109 ++-- .../HyphenationDecompounderTokenFilter.java | 36 +- .../analysis/IcuCollationAlternate.java | 12 +- .../analysis/IcuCollationCaseFirst.java | 12 +- .../analysis/IcuCollationDecomposition.java | 14 +- .../_types/analysis/IcuCollationStrength.java | 18 +- .../analysis/IcuCollationTokenFilter.java | 494 ++++++++++++++++ .../analysis/IcuFoldingTokenFilter.java | 41 +- .../analysis/IcuNormalizationTokenFilter.java | 43 +- .../_types/analysis/IcuNormalizationType.java | 12 +- .../_types/analysis/IcuTokenizer.java | 53 +- .../analysis/IcuTransformDirection.java | 12 +- .../analysis/IcuTransformTokenFilter.java | 63 ++- .../_types/analysis/KStemTokenFilter.java | 36 +- .../_types/analysis/KeepTypesMode.java | 12 +- .../_types/analysis/KeepTypesTokenFilter.java | 51 +- .../_types/analysis/KeepWordsTokenFilter.java | 56 +- .../analysis/KeywordMarkerTokenFilter.java | 61 +- .../KuromojiPartOfSpeechTokenFilter.java | 61 +- .../KuromojiReadingFormTokenFilter.java | 38 +- .../analysis/KuromojiStemmerTokenFilter.java | 38 +- .../_types/analysis/LengthTokenFilter.java | 83 ++- .../analysis/LimitTokenCountTokenFilter.java | 85 ++- .../_types/analysis/LowercaseTokenFilter.java | 38 +- .../analysis/MultiplexerTokenFilter.java | 83 ++- .../_types/analysis/NGramTokenFilter.java | 50 +- .../analysis/NoriPartOfSpeechTokenFilter.java | 60 +- .../analysis/PatternCaptureTokenFilter.java | 83 ++- .../analysis/PatternReplaceTokenFilter.java | 111 +++- .../analysis/PersianStemTokenFilter.java | 133 +++++ .../_types/analysis/PhoneticEncoder.java | 30 +- .../_types/analysis/PhoneticLanguage.java | 12 +- .../_types/analysis/PhoneticNameType.java | 14 +- .../_types/analysis/PhoneticRuleType.java | 12 +- .../_types/analysis/PhoneticTokenFilter.java | 83 ++- .../analysis/PorterStemTokenFilter.java | 34 +- .../_types/analysis/PredicateTokenFilter.java | 43 +- .../analysis/RemoveDuplicatesTokenFilter.java | 38 +- .../_types/analysis/ReverseTokenFilter.java | 34 +- .../_types/analysis/ShingleTokenFilter.java | 63 ++- .../analysis/SmartcnStopTokenFilter.java | 38 +- .../_types/analysis/SnowballLanguage.java | 12 +- .../_types/analysis/SnowballTokenFilter.java | 41 +- .../analysis/StemmerOverrideTokenFilter.java | 52 +- .../_types/analysis/StemmerTokenFilter.java | 58 +- .../_types/analysis/StopTokenFilter.java | 70 ++- .../_types/analysis/SynonymFormat.java | 12 +- .../analysis/SynonymGraphTokenFilter.java | 75 ++- .../_types/analysis/SynonymTokenFilter.java | 77 ++- .../_types/analysis/TokenFilter.java | 45 +- .../_types/analysis/TokenFilterBase.java | 32 +- .../_types/analysis/TokenFilterBuilders.java | 18 +- .../analysis/TokenFilterDefinition.java | 531 ++++++++---------- .../TokenFilterDefinitionBuilders.java | 202 +++---- .../TokenFilterDefinitionVariant.java | 8 +- .../_types/analysis/TokenizerBase.java | 32 +- .../_types/analysis/TrimTokenFilter.java | 36 +- .../_types/analysis/TruncateTokenFilter.java | 60 +- .../_types/analysis/UniqueTokenFilter.java | 38 +- .../_types/analysis/UppercaseTokenFilter.java | 34 +- .../WordDelimiterGraphTokenFilter.java | 127 +++-- .../analysis/WordDelimiterTokenFilter.java | 115 ++-- .../analysis/IcuCollationTokenFilter.java | 382 ------------- .../codegen/model/overrides/Overrides.java | 4 + 83 files changed, 3874 insertions(+), 1822 deletions(-) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/BuiltinScriptLanguage.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/InlineScript.java (71%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/Script.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/ScriptBase.java (71%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/ScriptBuilders.java (85%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/ScriptLanguage.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/StoredScriptId.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/AsciiFoldingTokenFilter.java (69%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/CommonGramsTokenFilter.java (81%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/CompoundWordTokenFilterBase.java (81%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/ConditionTokenFilter.java (77%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/DelimitedPayloadEncoding.java (84%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/DelimitedPayloadTokenFilter.java (68%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/DictionaryDecompounderTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/EdgeNGramSide.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/EdgeNGramTokenFilter.java (70%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/ElisionTokenFilter.java (63%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/FingerprintTokenFilter.java (66%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/HunspellTokenFilter.java (64%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/HyphenationDecompounderTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationAlternate.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationCaseFirst.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationDecomposition.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationStrength.java (84%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationTokenFilter.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuFoldingTokenFilter.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuNormalizationTokenFilter.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuNormalizationType.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuTokenizer.java (77%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuTransformDirection.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuTransformTokenFilter.java (73%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/KStemTokenFilter.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/KeepTypesMode.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/KeepTypesTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/KeepWordsTokenFilter.java (81%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/KeywordMarkerTokenFilter.java (81%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/KuromojiPartOfSpeechTokenFilter.java (76%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/KuromojiReadingFormTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/KuromojiStemmerTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/LengthTokenFilter.java (67%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/LimitTokenCountTokenFilter.java (64%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/LowercaseTokenFilter.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/MultiplexerTokenFilter.java (70%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/NGramTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/NoriPartOfSpeechTokenFilter.java (76%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PatternCaptureTokenFilter.java (70%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PatternReplaceTokenFilter.java (63%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/PersianStemTokenFilter.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PhoneticEncoder.java (86%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PhoneticLanguage.java (85%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PhoneticNameType.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PhoneticRuleType.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PhoneticTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PorterStemTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PredicateTokenFilter.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/RemoveDuplicatesTokenFilter.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/ReverseTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/ShingleTokenFilter.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/SmartcnStopTokenFilter.java (68%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/SnowballLanguage.java (86%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/SnowballTokenFilter.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/StemmerOverrideTokenFilter.java (81%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/StemmerTokenFilter.java (71%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/StopTokenFilter.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/SynonymFormat.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/SynonymGraphTokenFilter.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/SynonymTokenFilter.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/TokenFilter.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/TokenFilterBase.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/TokenFilterBuilders.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/TokenFilterDefinition.java (86%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/TokenFilterDefinitionBuilders.java (75%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/TokenFilterDefinitionVariant.java (85%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/TokenizerBase.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/TrimTokenFilter.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/TruncateTokenFilter.java (71%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/UniqueTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/UppercaseTokenFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/WordDelimiterGraphTokenFilter.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/WordDelimiterTokenFilter.java (83%) delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationTokenFilter.java diff --git a/UPGRADING.md b/UPGRADING.md index c14f4e082..d764e68ea 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -57,4 +57,20 @@ After: - Removed the `Runtime` variant from the `DynamicMapping` enum as it is not supported by OpenSearch. ### TypeMapping -- Removed the `runtime` field, getter and builder methods from `TypeMapping` as it is not supported by OpenSearch. \ No newline at end of file +- Removed the `runtime` field, getter and builder methods from `TypeMapping` as it is not supported by OpenSearch. + +### InlineScript +- The `lang` property now accepts a `ScriptLanguage` enum instead of a `String`. + +### IcuCollationDecomposition enum variants +- The `IcuCollationDecomposition.Identical` variant has been corrected to be `IcuCollationDecomposition.Canonical`. + +### IcuCollationTokenFilter property name casing +- The following fields, getters and builder methods on `IcuCollationTokenFilter` have had their casing corrected: + - `casefirst` -> `caseFirst` + - `caselevel` -> `caseLevel` + - `hiraganaquaternarymode` -> `hiraganaQuaternaryMode` + - `variabletop` -> `variableTop` + +### TokenFilterDefinition +- The `smartcn_stop` Builder method has been renamed to `smartcnStop`. \ No newline at end of file diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BuiltinScriptLanguage.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BuiltinScriptLanguage.java new file mode 100644 index 000000000..1efa80f96 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BuiltinScriptLanguage.java @@ -0,0 +1,69 @@ +/* + * 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. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch._types; + +import javax.annotation.Generated; +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +// typedef: _types.BuiltinScriptLanguage + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public enum BuiltinScriptLanguage implements JsonEnum { + Expression("expression"), + + Java("java"), + + Mustache("mustache"), + + Painless("painless"); + + private final String jsonValue; + + BuiltinScriptLanguage(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + BuiltinScriptLanguage.values() + ); +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineScript.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/InlineScript.java similarity index 71% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineScript.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/InlineScript.java index be2177029..fd2cde01a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineScript.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/InlineScript.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; import jakarta.json.stream.JsonGenerator; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -47,26 +54,28 @@ // typedef: _types.InlineScript @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class InlineScript extends ScriptBase { + @Nullable - private final String lang; + private final ScriptLanguage lang; + @Nonnull private final Map options; + @Nonnull private final String source; // --------------------------------------------------------------------------------------------- private InlineScript(Builder builder) { super(builder); - this.lang = builder.lang; this.options = ApiTypeHelper.unmodifiable(builder.options); this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); - } - public static InlineScript of(Function> fn) { + public static InlineScript of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -74,46 +83,48 @@ public static InlineScript of(Function> fn) * API name: {@code lang} */ @Nullable - public final String lang() { + public final ScriptLanguage lang() { return this.lang; } /** * API name: {@code options} */ + @Nonnull public final Map options() { return this.options; } /** - * Required - API name: {@code source} + * Required - The script source. + *

+ * API name: {@code source} + *

*/ + @Nonnull public final String source() { return this.source; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - super.serializeInternal(generator, mapper); if (this.lang != null) { generator.writeKey("lang"); - generator.write(this.lang); - + this.lang.serialize(generator, mapper); } + if (ApiTypeHelper.isDefined(this.options)) { generator.writeKey("options"); generator.writeStartObject(); for (Map.Entry item0 : this.options.entrySet()) { generator.writeKey(item0.getKey()); generator.write(item0.getValue()); - } generator.writeEnd(); - } + generator.writeKey("source"); generator.write(this.source); - } // --------------------------------------------------------------------------------------------- @@ -121,28 +132,34 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link InlineScript}. */ - public static class Builder extends ScriptBase.AbstractBuilder implements ObjectBuilder { @Nullable - private String lang; - + private ScriptLanguage lang; @Nullable private Map options; - private String source; /** * API name: {@code lang} */ - public final Builder lang(@Nullable String value) { + public final Builder lang(@Nullable ScriptLanguage value) { this.lang = value; return this; } + /** + * API name: {@code lang} + */ + public final Builder lang(Function> fn) { + return lang(fn.apply(new ScriptLanguage.Builder()).build()); + } + /** * API name: {@code options} + * *

- * Adds all entries of map to options. + * Adds all elements of map to options. + *

*/ public final Builder options(Map map) { this.options = _mapPutAll(this.options, map); @@ -151,8 +168,10 @@ public final Builder options(Map map) { /** * API name: {@code options} + * *

* Adds an entry to options. + *

*/ public final Builder options(String key, String value) { this.options = _mapPut(this.options, key, value); @@ -160,7 +179,10 @@ public final Builder options(String key, String value) { } /** - * Required - API name: {@code source} + * Required - The script source. + *

+ * API name: {@code source} + *

*/ public final Builder source(String value) { this.source = value; @@ -175,8 +197,7 @@ protected Builder self() { /** * Builds a {@link InlineScript}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public InlineScript build() { _checkSingleUse(); @@ -196,13 +217,31 @@ public InlineScript build() { ); protected static void setupInlineScriptDeserializer(ObjectDeserializer op) { - ScriptBase.setupScriptBaseDeserializer(op); - op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang"); + setupScriptBaseDeserializer(op); + op.add(Builder::lang, ScriptLanguage._DESERIALIZER, "lang"); op.add(Builder::options, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "options"); op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); op.shortcutProperty("source"); + } + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Objects.hashCode(this.lang); + result = 31 * result + Objects.hashCode(this.options); + result = 31 * result + this.source.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + InlineScript other = (InlineScript) o; + return Objects.equals(this.lang, other.lang) && Objects.equals(this.options, other.options) && this.source.equals(other.source); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Script.java similarity index 79% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/Script.java index 6f969b8f5..811438381 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Script.java @@ -30,14 +30,21 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; 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.PlainJsonSerializable; import org.opensearch.client.json.UnionDeserializer; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; @@ -48,12 +55,14 @@ // typedef: _types.Script @JsonpDeserializable -public class Script implements TaggedUnion, JsonpSerializable { - +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class Script implements TaggedUnion, PlainJsonSerializable { + /** + * {@link Script} variant kinds. + */ public enum Kind { Inline, Stored - } private final Kind _kind; @@ -75,13 +84,11 @@ private Script(Kind kind, Object value) { } private Script(Builder builder) { - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - } - public static Script of(Function> fn) { + public static Script of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -95,8 +102,7 @@ public boolean isInline() { /** * Get the {@code inline} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code inline} kind. + * @throws IllegalStateException if the current variant is not the {@code inline} kind. */ public InlineScript inline() { return TaggedUnionUtils.get(this, Kind.Inline); @@ -112,8 +118,7 @@ public boolean isStored() { /** * Get the {@code stored} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code stored} kind. + * @throws IllegalStateException if the current variant is not the {@code stored} kind. */ public StoredScriptId stored() { return TaggedUnionUtils.get(this, Kind.Stored); @@ -124,7 +129,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { if (_value instanceof JsonpSerializable) { ((JsonpSerializable) _value).serialize(generator, mapper); } - } public static class Builder extends ObjectBuilderBase implements ObjectBuilder