From 6b5671fb176715f3123263c762eef9c205bb091d Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Thu, 21 Nov 2024 12:52:19 +1300 Subject: [PATCH] Generate IcuCollationKeywordProperty Signed-off-by: Thomas Farr --- CHANGELOG.md | 2 + .../analysis/IcuCollationAlternate.java | 12 +- .../analysis/IcuCollationCaseFirst.java | 12 +- .../analysis/IcuCollationDecomposition.java | 14 +- .../_types/analysis/IcuCollationStrength.java | 18 +- .../mapping/IcuCollationKeywordProperty.java | 331 +++++++++++++----- .../codegen/model/overrides/Overrides.java | 1 + 7 files changed, 293 insertions(+), 97 deletions(-) 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%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java (62%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b01c1c048e..7376b1e3dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased 2.x] ### Added +- Added support for `IcuCollationKeywordProperty`'s `country`, `language` and `variant` properties ([#]()) ### Dependencies - Bumps `org.junit:junit-bom` from 5.10.2 to 5.11.3 @@ -14,6 +15,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Removed ### Fixed +- Fixed `IcuCollationDecomposition`'s variants to align with those supported by OpenSearch ([#]()) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationAlternate.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationAlternate.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationAlternate.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationAlternate.java index 21f8aa37a8..6adf9af17d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationAlternate.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationAlternate.java @@ -30,18 +30,24 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.analysis; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.analysis.IcuCollationAlternate + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum IcuCollationAlternate implements JsonEnum { - Shifted("shifted"), - NonIgnorable("non-ignorable"), - ; + Shifted("shifted"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationCaseFirst.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationCaseFirst.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationCaseFirst.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationCaseFirst.java index ed01016a18..02775c9aa7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationCaseFirst.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationCaseFirst.java @@ -30,18 +30,24 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.analysis; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.analysis.IcuCollationCaseFirst + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum IcuCollationCaseFirst implements JsonEnum { Lower("lower"), - Upper("upper"), - - ; + Upper("upper"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationDecomposition.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationDecomposition.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationDecomposition.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationDecomposition.java index a6b5e0cfc4..44395d6ea4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationDecomposition.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationDecomposition.java @@ -30,18 +30,24 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.analysis; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.analysis.IcuCollationDecomposition + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum IcuCollationDecomposition implements JsonEnum { - No("no"), - - Identical("identical"), + Canonical("canonical"), - ; + No("no"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationStrength.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationStrength.java similarity index 84% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationStrength.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationStrength.java index bca73489cd..c9e6e1b61b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationStrength.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/IcuCollationStrength.java @@ -30,24 +30,30 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.analysis; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.analysis.IcuCollationStrength + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum IcuCollationStrength implements JsonEnum { - Primary("primary"), - - Secondary("secondary"), + Identical("identical"), - Tertiary("tertiary"), + Primary("primary"), Quaternary("quaternary"), - Identical("identical"), + Secondary("secondary"), - ; + Tertiary("tertiary"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java similarity index 62% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java index 0876e46265..7a6715cc8b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java @@ -6,10 +6,40 @@ * 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.mapping; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -22,27 +52,23 @@ import org.opensearch.client.opensearch._types.analysis.IcuCollationStrength; import org.opensearch.client.util.ObjectBuilder; -// typedef: _types.mapping.ICUCollationKeywordProperty +// typedef: _types.mapping.IcuCollationKeywordProperty @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class IcuCollationKeywordProperty extends DocValuesPropertyBase implements PropertyVariant { @Nullable - private final Boolean index; - - @Nullable - private final String nullValue; - - // Collation Options + private final IcuCollationAlternate alternate; @Nullable - private final IcuCollationAlternate alternate; + private final IcuCollationCaseFirst caseFirst; @Nullable private final Boolean caseLevel; @Nullable - private final IcuCollationCaseFirst caseFirst; + private final String country; @Nullable private final IcuCollationDecomposition decomposition; @@ -50,6 +76,15 @@ public class IcuCollationKeywordProperty extends DocValuesPropertyBase implement @Nullable private final Boolean hiraganaQuaternaryMode; + @Nullable + private final Boolean index; + + @Nullable + private final String language; + + @Nullable + private final String nullValue; + @Nullable private final Boolean numeric; @@ -59,71 +94,78 @@ public class IcuCollationKeywordProperty extends DocValuesPropertyBase implement @Nullable private final String variableTop; + @Nullable + private final String variant; + // --------------------------------------------------------------------------------------------- private IcuCollationKeywordProperty(Builder builder) { super(builder); - this.index = builder.index; - this.nullValue = builder.nullValue; this.alternate = builder.alternate; - this.caseLevel = builder.caseLevel; this.caseFirst = builder.caseFirst; + this.caseLevel = builder.caseLevel; + this.country = builder.country; this.decomposition = builder.decomposition; this.hiraganaQuaternaryMode = builder.hiraganaQuaternaryMode; + this.index = builder.index; + this.language = builder.language; + this.nullValue = builder.nullValue; this.numeric = builder.numeric; this.strength = builder.strength; this.variableTop = builder.variableTop; + this.variant = builder.variant; } - public static IcuCollationKeywordProperty of(Function> fn) { + public static IcuCollationKeywordProperty of( + Function> fn + ) { return fn.apply(new Builder()).build(); } + /** + * {@link Property} variant kind. + */ @Override public Property.Kind _propertyKind() { return Property.Kind.IcuCollationKeyword; } /** - * API name: {@code index} + * API name: {@code alternate} */ @Nullable - public final Boolean index() { - return this.index; + public final IcuCollationAlternate alternate() { + return this.alternate; } /** - * API name: {@code null_value} + * API name: {@code case_first} */ @Nullable - public final String nullValue() { - return this.nullValue; - } - - /** - * API name: {@code alternate} - */ - public final IcuCollationAlternate alternate() { - return this.alternate; + public final IcuCollationCaseFirst caseFirst() { + return this.caseFirst; } /** * API name: {@code case_level} */ + @Nullable public final Boolean caseLevel() { return this.caseLevel; } /** - * API name: {@code case_first} + * API name: {@code country} */ - public final IcuCollationCaseFirst caseFirst() { - return this.caseFirst; + @Nullable + public final String country() { + return this.country; } /** * API name: {@code decomposition} */ + @Nullable public final IcuCollationDecomposition decomposition() { return this.decomposition; } @@ -131,13 +173,39 @@ public final IcuCollationDecomposition decomposition() { /** * API name: {@code hiragana_quaternary_mode} */ + @Nullable public final Boolean hiraganaQuaternaryMode() { return this.hiraganaQuaternaryMode; } + /** + * API name: {@code index} + */ + @Nullable + public final Boolean index() { + return this.index; + } + + /** + * API name: {@code language} + */ + @Nullable + public final String language() { + return this.language; + } + + /** + * API name: {@code null_value} + */ + @Nullable + public final String nullValue() { + return this.nullValue; + } + /** * API name: {@code numeric} */ + @Nullable public final Boolean numeric() { return this.numeric; } @@ -145,6 +213,7 @@ public final Boolean numeric() { /** * API name: {@code strength} */ + @Nullable public final IcuCollationStrength strength() { return this.strength; } @@ -152,53 +221,86 @@ public final IcuCollationStrength strength() { /** * API name: {@code variable_top} */ + @Nullable public final String variableTop() { return this.variableTop; } + /** + * API name: {@code variant} + */ + @Nullable + public final String variant() { + return this.variant; + } + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "icu_collation_keyword"); super.serializeInternal(generator, mapper); - if (this.index != null) { - generator.writeKey("index"); - generator.write(this.index); - } - if (this.nullValue != null) { - generator.writeKey("null_value"); - generator.write(this.nullValue); - } if (this.alternate != null) { generator.writeKey("alternate"); - generator.write(this.alternate.jsonValue()); + this.alternate.serialize(generator, mapper); } + + if (this.caseFirst != null) { + generator.writeKey("case_first"); + this.caseFirst.serialize(generator, mapper); + } + if (this.caseLevel != null) { generator.writeKey("case_level"); generator.write(this.caseLevel); } - if (this.caseFirst != null) { - generator.writeKey("case_first"); - generator.write(this.caseFirst.jsonValue()); + + if (this.country != null) { + generator.writeKey("country"); + generator.write(this.country); } + if (this.decomposition != null) { generator.writeKey("decomposition"); - generator.write(this.decomposition.jsonValue()); + this.decomposition.serialize(generator, mapper); } + if (this.hiraganaQuaternaryMode != null) { generator.writeKey("hiragana_quaternary_mode"); generator.write(this.hiraganaQuaternaryMode); } + + if (this.index != null) { + generator.writeKey("index"); + generator.write(this.index); + } + + if (this.language != null) { + generator.writeKey("language"); + generator.write(this.language); + } + + if (this.nullValue != null) { + generator.writeKey("null_value"); + generator.write(this.nullValue); + } + if (this.numeric != null) { generator.writeKey("numeric"); generator.write(this.numeric); } + if (this.strength != null) { generator.writeKey("strength"); - generator.write(this.strength.jsonValue()); + this.strength.serialize(generator, mapper); } + if (this.variableTop != null) { generator.writeKey("variable_top"); generator.write(this.variableTop); } + + if (this.variant != null) { + generator.writeKey("variant"); + generator.write(this.variant); + } } // --------------------------------------------------------------------------------------------- @@ -206,61 +308,49 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IcuCollationKeywordProperty}. */ - public static class Builder extends DocValuesPropertyBase.AbstractBuilder implements ObjectBuilder { - @Nullable - private Boolean index; - - @Nullable - private String nullValue; - @Nullable private IcuCollationAlternate alternate; - + @Nullable + private IcuCollationCaseFirst caseFirst; @Nullable private Boolean caseLevel; - @Nullable - private IcuCollationCaseFirst caseFirst; - + private String country; @Nullable private IcuCollationDecomposition decomposition; - @Nullable private Boolean hiraganaQuaternaryMode; - + @Nullable + private Boolean index; + @Nullable + private String language; + @Nullable + private String nullValue; @Nullable private Boolean numeric; - @Nullable private IcuCollationStrength strength; - @Nullable private String variableTop; + @Nullable + private String variant; /** - * API name: {@code index} - */ - public final Builder index(@Nullable Boolean value) { - this.index = value; - return this; - } - - /** - * API name: {@code null_value} + * API name: {@code alternate} */ - public final Builder nullValue(@Nullable String value) { - this.nullValue = value; + public final Builder alternate(@Nullable IcuCollationAlternate value) { + this.alternate = value; return this; } /** - * API name: {@code alternate} + * API name: {@code case_first} */ - public final Builder alternate(@Nullable IcuCollationAlternate value) { - this.alternate = value; + public final Builder caseFirst(@Nullable IcuCollationCaseFirst value) { + this.caseFirst = value; return this; } @@ -273,10 +363,10 @@ public final Builder caseLevel(@Nullable Boolean value) { } /** - * API name: {@code case_first} + * API name: {@code country} */ - public final Builder caseFirst(@Nullable IcuCollationCaseFirst value) { - this.caseFirst = value; + public final Builder country(@Nullable String value) { + this.country = value; return this; } @@ -296,6 +386,30 @@ public final Builder hiraganaQuaternaryMode(@Nullable Boolean value) { return this; } + /** + * API name: {@code index} + */ + public final Builder index(@Nullable Boolean value) { + this.index = value; + return this; + } + + /** + * API name: {@code language} + */ + public final Builder language(@Nullable String value) { + this.language = value; + return this; + } + + /** + * API name: {@code null_value} + */ + public final Builder nullValue(@Nullable String value) { + this.nullValue = value; + return this; + } + /** * API name: {@code numeric} */ @@ -320,6 +434,14 @@ public final Builder variableTop(@Nullable String value) { return this; } + /** + * API name: {@code variant} + */ + public final Builder variant(@Nullable String value) { + this.variant = value; + return this; + } + @Override protected Builder self() { return this; @@ -328,11 +450,11 @@ protected Builder self() { /** * Builds a {@link IcuCollationKeywordProperty}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IcuCollationKeywordProperty build() { _checkSingleUse(); + return new IcuCollationKeywordProperty(this); } } @@ -348,16 +470,63 @@ public IcuCollationKeywordProperty build() { ); protected static void setupIcuCollationKeywordPropertyDeserializer(ObjectDeserializer op) { - DocValuesPropertyBase.setupDocValuesPropertyBaseDeserializer(op); - op.add(Builder::index, JsonpDeserializer.booleanDeserializer(), "index"); - op.add(Builder::nullValue, JsonpDeserializer.stringDeserializer(), "null_value"); + setupDocValuesPropertyBaseDeserializer(op); op.add(Builder::alternate, IcuCollationAlternate._DESERIALIZER, "alternate"); - op.add(Builder::caseLevel, JsonpDeserializer.booleanDeserializer(), "case_level"); op.add(Builder::caseFirst, IcuCollationCaseFirst._DESERIALIZER, "case_first"); + op.add(Builder::caseLevel, JsonpDeserializer.booleanDeserializer(), "case_level"); + op.add(Builder::country, JsonpDeserializer.stringDeserializer(), "country"); op.add(Builder::decomposition, IcuCollationDecomposition._DESERIALIZER, "decomposition"); op.add(Builder::hiraganaQuaternaryMode, JsonpDeserializer.booleanDeserializer(), "hiragana_quaternary_mode"); + op.add(Builder::index, JsonpDeserializer.booleanDeserializer(), "index"); + op.add(Builder::language, JsonpDeserializer.stringDeserializer(), "language"); + op.add(Builder::nullValue, JsonpDeserializer.stringDeserializer(), "null_value"); op.add(Builder::numeric, JsonpDeserializer.booleanDeserializer(), "numeric"); op.add(Builder::strength, IcuCollationStrength._DESERIALIZER, "strength"); op.add(Builder::variableTop, JsonpDeserializer.stringDeserializer(), "variable_top"); + op.add(Builder::variant, JsonpDeserializer.stringDeserializer(), "variant"); + + op.ignore("type"); + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Objects.hashCode(this.alternate); + result = 31 * result + Objects.hashCode(this.caseFirst); + result = 31 * result + Objects.hashCode(this.caseLevel); + result = 31 * result + Objects.hashCode(this.country); + result = 31 * result + Objects.hashCode(this.decomposition); + result = 31 * result + Objects.hashCode(this.hiraganaQuaternaryMode); + result = 31 * result + Objects.hashCode(this.index); + result = 31 * result + Objects.hashCode(this.language); + result = 31 * result + Objects.hashCode(this.nullValue); + result = 31 * result + Objects.hashCode(this.numeric); + result = 31 * result + Objects.hashCode(this.strength); + result = 31 * result + Objects.hashCode(this.variableTop); + result = 31 * result + Objects.hashCode(this.variant); + 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; + IcuCollationKeywordProperty other = (IcuCollationKeywordProperty) o; + return Objects.equals(this.alternate, other.alternate) + && Objects.equals(this.caseFirst, other.caseFirst) + && Objects.equals(this.caseLevel, other.caseLevel) + && Objects.equals(this.country, other.country) + && Objects.equals(this.decomposition, other.decomposition) + && Objects.equals(this.hiraganaQuaternaryMode, other.hiraganaQuaternaryMode) + && Objects.equals(this.index, other.index) + && Objects.equals(this.language, other.language) + && Objects.equals(this.nullValue, other.nullValue) + && Objects.equals(this.numeric, other.numeric) + && Objects.equals(this.strength, other.strength) + && Objects.equals(this.variableTop, other.variableTop) + && Objects.equals(this.variant, other.variant); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java index 934b3ab586..e9d56d54f5 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java @@ -35,6 +35,7 @@ private static JsonPointer schema(String namespace, String name) { // TODO: Remove this to generate property mapping types .with(schema("_common.mapping", "Property"), so -> so.withShouldGenerate(ShouldGenerate.Never)) .with(schema("_common.mapping", "PropertyBase"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(schema("_common.mapping", "IcuCollationKeywordProperty"), so -> so.withShouldGenerate(ShouldGenerate.Always)) .with(schema("_common.mapping", "KnnVectorProperty"), so -> so.withShouldGenerate(ShouldGenerate.Always)) // TODO: Remove this to generate query types