From 14d27fdcd0e8a6dd8ff2bf42429fdb07d45d9a98 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 12 Nov 2024 15:48:05 +1300 Subject: [PATCH] Generate CharFilter variants Signed-off-by: Thomas Farr --- .../_types/analysis/CharFilter.java | 45 ++++++++---- .../_types/analysis/CharFilterBase.java | 32 ++++++-- .../_types/analysis/CharFilterBuilders.java | 18 +++-- .../_types/analysis/CharFilterDefinition.java | 73 +++++++++---------- .../CharFilterDefinitionBuilders.java | 23 +++--- .../analysis/CharFilterDefinitionVariant.java | 8 +- .../_types/analysis/HtmlStripCharFilter.java | 34 +++++++-- .../analysis/IcuNormalizationCharFilter.java | 42 ++++++++--- .../KuromojiIterationMarkCharFilter.java | 42 ++++++++--- .../_types/analysis/MappingCharFilter.java | 59 ++++++++++----- .../analysis/PatternReplaceCharFilter.java | 56 ++++++++++---- .../codegen/model/overrides/Overrides.java | 1 + 12 files changed, 295 insertions(+), 138 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/CharFilter.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBase.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBuilders.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/CharFilterDefinition.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/CharFilterDefinitionBuilders.java (81%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/CharFilterDefinitionVariant.java (85%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/HtmlStripCharFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/IcuNormalizationCharFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/KuromojiIterationMarkCharFilter.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/MappingCharFilter.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/analysis/PatternReplaceCharFilter.java (79%) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilter.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilter.java similarity index 79% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilter.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilter.java index 2bda7e61b6..786b719b7f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilter.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilter.java @@ -30,14 +30,21 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.analysis; 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.analysis.CharFilter @JsonpDeserializable -public class CharFilter implements TaggedUnion, JsonpSerializable { - +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class CharFilter implements TaggedUnion, PlainJsonSerializable { + /** + * {@link CharFilter} variant kinds. + */ public enum Kind { Definition, Name - } private final Kind _kind; @@ -75,13 +84,11 @@ private CharFilter(Kind kind, Object value) { } private CharFilter(Builder builder) { - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - } - public static CharFilter of(Function> fn) { + public static CharFilter of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -95,8 +102,7 @@ public boolean isDefinition() { /** * Get the {@code definition} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code definition} kind. + * @throws IllegalStateException if the current variant is not the {@code definition} kind. */ public CharFilterDefinition definition() { return TaggedUnionUtils.get(this, Kind.Definition); @@ -112,8 +118,7 @@ public boolean isName() { /** * Get the {@code name} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code name} kind. + * @throws IllegalStateException if the current variant is not the {@code name} kind. */ public String name() { return TaggedUnionUtils.get(this, Kind.Name); @@ -127,11 +132,9 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { switch (_kind) { case Name: generator.write(((String) this._value)); - break; } } - } public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @@ -154,11 +157,11 @@ public ObjectBuilder name(String v) { return this; } + @Override public CharFilter build() { _checkSingleUse(); return new CharFilter(this); } - } private static JsonpDeserializer buildCharFilterDeserializer() { @@ -169,4 +172,20 @@ private static JsonpDeserializer buildCharFilterDeserializer() { } public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.lazy(CharFilter::buildCharFilterDeserializer); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this._kind); + result = 31 * result + Objects.hashCode(this._value); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + CharFilter other = (CharFilter) o; + return Objects.equals(this._kind, other._kind) && Objects.equals(this._value, other._value); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBase.java similarity index 79% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBase.java index c30cd911d1..1bea5b8ef0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBase.java @@ -30,9 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.analysis; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -42,16 +48,16 @@ // typedef: _types.analysis.CharFilterBase +@Generated("org.opensearch.client.codegen.CodeGenerator") public abstract class CharFilterBase implements PlainJsonSerializable { + @Nullable private final String version; // --------------------------------------------------------------------------------------------- protected CharFilterBase(AbstractBuilder builder) { - this.version = builder.version; - } /** @@ -65,6 +71,7 @@ public final String version() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -72,15 +79,14 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.version != null) { generator.writeKey("version"); generator.write(this.version); - } - } + // --------------------------------------------------------------------------------------------- + protected abstract static class AbstractBuilder> extends ObjectBuilderBase { @Nullable private String version; @@ -94,14 +100,26 @@ public final BuilderT version(@Nullable String value) { } protected abstract BuilderT self(); - } // --------------------------------------------------------------------------------------------- - protected static > void setupCharFilterBaseDeserializer(ObjectDeserializer op) { + protected static > void setupCharFilterBaseDeserializer(ObjectDeserializer op) { op.add(AbstractBuilder::version, JsonpDeserializer.stringDeserializer(), "version"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.version); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + CharFilterBase other = (CharFilterBase) o; + return Objects.equals(this.version, other.version); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBuilders.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBuilders.java similarity index 80% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBuilders.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBuilders.java index 977e4fe4fe..779cfc3fd0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBuilders.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilterBuilders.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; + /** + *

* Builders for {@link CharFilter} variants. + *

*

- * Variants name are not available here as they don't have a - * dedicated class. Use {@link CharFilter}'s builder for these. - * + * Variants name are not available here as they don't have a dedicated class. Use {@link CharFilter}'s builder for these. + *

*/ +@Generated("org.opensearch.client.codegen.CodeGenerator") public class CharFilterBuilders { private CharFilterBuilders() {} /** - * Creates a builder for the {@link CharFilterDefinition definition} - * {@code CharFilter} variant. + * Creates a builder for the {@link CharFilterDefinition definition} {@code CharFilter} variant. */ public static CharFilterDefinition.Builder definition() { return new CharFilterDefinition.Builder(); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilterDefinition.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilterDefinition.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilterDefinition.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilterDefinition.java index d5b440a81b..f12942a6f8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CharFilterDefinition.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/CharFilterDefinition.java @@ -30,17 +30,23 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.analysis; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; 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.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; @@ -50,27 +56,17 @@ // typedef: _types.analysis.CharFilterDefinition @JsonpDeserializable -public class CharFilterDefinition implements TaggedUnion, JsonpSerializable { - +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class CharFilterDefinition implements TaggedUnion, PlainJsonSerializable { /** * {@link CharFilterDefinition} variant kinds. */ - /** - * {@link CharFilterDefinition} variant kinds. - */ - public enum Kind implements JsonEnum { HtmlStrip("html_strip"), - IcuNormalizer("icu_normalizer"), - KuromojiIterationMark("kuromoji_iteration_mark"), - Mapping("mapping"), - - PatternReplace("pattern_replace"), - - ; + PatternReplace("pattern_replace"); private final String jsonValue; @@ -78,10 +74,10 @@ public enum Kind implements JsonEnum { this.jsonValue = jsonValue; } + @Override public String jsonValue() { - return this.jsonValue; + return jsonValue; } - } private final Kind _kind; @@ -98,20 +94,16 @@ public final CharFilterDefinitionVariant _get() { } public CharFilterDefinition(CharFilterDefinitionVariant value) { - this._kind = ApiTypeHelper.requireNonNull(value._charFilterDefinitionKind(), this, ""); this._value = ApiTypeHelper.requireNonNull(value, this, ""); - } private CharFilterDefinition(Builder builder) { - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - } - public static CharFilterDefinition of(Function> fn) { + public static CharFilterDefinition of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -125,8 +117,7 @@ public boolean isHtmlStrip() { /** * Get the {@code html_strip} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code html_strip} kind. + * @throws IllegalStateException if the current variant is not the {@code html_strip} kind. */ public HtmlStripCharFilter htmlStrip() { return TaggedUnionUtils.get(this, Kind.HtmlStrip); @@ -142,8 +133,7 @@ public boolean isIcuNormalizer() { /** * Get the {@code icu_normalizer} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code icu_normalizer} kind. + * @throws IllegalStateException if the current variant is not the {@code icu_normalizer} kind. */ public IcuNormalizationCharFilter icuNormalizer() { return TaggedUnionUtils.get(this, Kind.IcuNormalizer); @@ -159,9 +149,7 @@ public boolean isKuromojiIterationMark() { /** * Get the {@code kuromoji_iteration_mark} variant value. * - * @throws IllegalStateException - * if the current variant is not of the - * {@code kuromoji_iteration_mark} kind. + * @throws IllegalStateException if the current variant is not the {@code kuromoji_iteration_mark} kind. */ public KuromojiIterationMarkCharFilter kuromojiIterationMark() { return TaggedUnionUtils.get(this, Kind.KuromojiIterationMark); @@ -177,8 +165,7 @@ public boolean isMapping() { /** * Get the {@code mapping} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code mapping} kind. + * @throws IllegalStateException if the current variant is not the {@code mapping} kind. */ public MappingCharFilter mapping() { return TaggedUnionUtils.get(this, Kind.Mapping); @@ -194,9 +181,7 @@ public boolean isPatternReplace() { /** * Get the {@code pattern_replace} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code pattern_replace} - * kind. + * @throws IllegalStateException if the current variant is not the {@code pattern_replace} kind. */ public PatternReplaceCharFilter patternReplace() { return TaggedUnionUtils.get(this, Kind.PatternReplace); @@ -204,9 +189,7 @@ public PatternReplaceCharFilter patternReplace() { @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { - mapper.serialize(_value, generator); - } public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @@ -269,15 +252,14 @@ public ObjectBuilder patternReplace( return this.patternReplace(fn.apply(new PatternReplaceCharFilter.Builder()).build()); } + @Override public CharFilterDefinition build() { _checkSingleUse(); return new CharFilterDefinition(this); } - } protected static void setupCharFilterDefinitionDeserializer(ObjectDeserializer op) { - op.add(Builder::htmlStrip, HtmlStripCharFilter._DESERIALIZER, "html_strip"); op.add(Builder::icuNormalizer, IcuNormalizationCharFilter._DESERIALIZER, "icu_normalizer"); op.add(Builder::kuromojiIterationMark, KuromojiIterationMarkCharFilter._DESERIALIZER, "kuromoji_iteration_mark"); @@ -285,7 +267,6 @@ protected static void setupCharFilterDefinitionDeserializer(ObjectDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( @@ -293,4 +274,20 @@ protected static void setupCharFilterDefinitionDeserializer(ObjectDeserializer> fn) { + public static HtmlStripCharFilter of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * CharFilterDefinition variant kind. + * {@link CharFilterDefinition} variant kind. */ @Override public CharFilterDefinition.Kind _charFilterDefinitionKind() { @@ -65,10 +71,8 @@ public CharFilterDefinition.Kind _charFilterDefinitionKind() { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.write("type", "html_strip"); super.serializeInternal(generator, mapper); - } // --------------------------------------------------------------------------------------------- @@ -76,8 +80,8 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link HtmlStripCharFilter}. */ - public static class Builder extends CharFilterBase.AbstractBuilder implements ObjectBuilder { + @Override protected Builder self() { return this; @@ -86,8 +90,7 @@ protected Builder self() { /** * Builds a {@link HtmlStripCharFilter}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public HtmlStripCharFilter build() { _checkSingleUse(); @@ -112,4 +115,19 @@ protected static void setupHtmlStripCharFilterDeserializer(ObjectDeserializer> fn) { + public static IcuNormalizationCharFilter of( + Function> fn + ) { return fn.apply(new Builder()).build(); } /** - * CharFilterDefinition variant kind. + * {@link CharFilterDefinition} variant kind. */ @Override public CharFilterDefinition.Kind _charFilterDefinitionKind() { @@ -91,18 +99,17 @@ public final IcuNormalizationType name() { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.write("type", "icu_normalizer"); super.serializeInternal(generator, mapper); if (this.mode != null) { generator.writeKey("mode"); this.mode.serialize(generator, mapper); } + if (this.name != null) { generator.writeKey("name"); this.name.serialize(generator, mapper); } - } // --------------------------------------------------------------------------------------------- @@ -110,11 +117,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IcuNormalizationCharFilter}. */ - public static class Builder extends CharFilterBase.AbstractBuilder implements ObjectBuilder { @Nullable private IcuNormalizationMode mode; - @Nullable private IcuNormalizationType name; @@ -142,8 +147,7 @@ protected Builder self() { /** * Builds a {@link IcuNormalizationCharFilter}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IcuNormalizationCharFilter build() { _checkSingleUse(); @@ -170,4 +174,22 @@ protected static void setupIcuNormalizationCharFilterDeserializer(ObjectDeserial op.ignore("type"); } + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Objects.hashCode(this.mode); + result = 31 * result + Objects.hashCode(this.name); + 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; + IcuNormalizationCharFilter other = (IcuNormalizationCharFilter) o; + return Objects.equals(this.mode, other.mode) && Objects.equals(this.name, other.name); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/KuromojiIterationMarkCharFilter.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/KuromojiIterationMarkCharFilter.java similarity index 80% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/KuromojiIterationMarkCharFilter.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/KuromojiIterationMarkCharFilter.java index 70e8dff88f..83b3f956dd 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/KuromojiIterationMarkCharFilter.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/KuromojiIterationMarkCharFilter.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.analysis; import jakarta.json.stream.JsonGenerator; 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; @@ -45,7 +50,9 @@ // typedef: _types.analysis.KuromojiIterationMarkCharFilter @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class KuromojiIterationMarkCharFilter extends CharFilterBase implements CharFilterDefinitionVariant { + private final boolean normalizeKana; private final boolean normalizeKanji; @@ -54,18 +61,18 @@ public class KuromojiIterationMarkCharFilter extends CharFilterBase implements C private KuromojiIterationMarkCharFilter(Builder builder) { super(builder); - this.normalizeKana = ApiTypeHelper.requireNonNull(builder.normalizeKana, this, "normalizeKana"); this.normalizeKanji = ApiTypeHelper.requireNonNull(builder.normalizeKanji, this, "normalizeKanji"); - } - public static KuromojiIterationMarkCharFilter of(Function> fn) { + public static KuromojiIterationMarkCharFilter of( + Function> fn + ) { return fn.apply(new Builder()).build(); } /** - * CharFilterDefinition variant kind. + * {@link CharFilterDefinition} variant kind. */ @Override public CharFilterDefinition.Kind _charFilterDefinitionKind() { @@ -87,7 +94,6 @@ public final boolean normalizeKanji() { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.write("type", "kuromoji_iteration_mark"); super.serializeInternal(generator, mapper); generator.writeKey("normalize_kana"); @@ -95,7 +101,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("normalize_kanji"); generator.write(this.normalizeKanji); - } // --------------------------------------------------------------------------------------------- @@ -103,10 +108,8 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link KuromojiIterationMarkCharFilter}. */ - public static class Builder extends CharFilterBase.AbstractBuilder implements ObjectBuilder { private Boolean normalizeKana; - private Boolean normalizeKanji; /** @@ -133,8 +136,7 @@ protected Builder self() { /** * Builds a {@link KuromojiIterationMarkCharFilter}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public KuromojiIterationMarkCharFilter build() { _checkSingleUse(); @@ -154,11 +156,29 @@ public KuromojiIterationMarkCharFilter build() { ); protected static void setupKuromojiIterationMarkCharFilterDeserializer(ObjectDeserializer op) { - CharFilterBase.setupCharFilterBaseDeserializer(op); + setupCharFilterBaseDeserializer(op); op.add(Builder::normalizeKana, JsonpDeserializer.booleanDeserializer(), "normalize_kana"); op.add(Builder::normalizeKanji, JsonpDeserializer.booleanDeserializer(), "normalize_kanji"); op.ignore("type"); } + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Boolean.hashCode(this.normalizeKana); + result = 31 * result + Boolean.hashCode(this.normalizeKanji); + 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; + KuromojiIterationMarkCharFilter other = (KuromojiIterationMarkCharFilter) o; + return this.normalizeKana == other.normalizeKana && this.normalizeKanji == other.normalizeKanji; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/MappingCharFilter.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/MappingCharFilter.java similarity index 78% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/MappingCharFilter.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/MappingCharFilter.java index 78cc3c312f..eae1f4f1d0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/MappingCharFilter.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/MappingCharFilter.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.analysis; import jakarta.json.stream.JsonGenerator; import java.util.List; +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,7 +54,10 @@ // typedef: _types.analysis.MappingCharFilter @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class MappingCharFilter extends CharFilterBase implements CharFilterDefinitionVariant { + + @Nonnull private final List mappings; @Nullable @@ -57,18 +67,16 @@ public class MappingCharFilter extends CharFilterBase implements CharFilterDefin private MappingCharFilter(Builder builder) { super(builder); - - this.mappings = ApiTypeHelper.unmodifiableRequired(builder.mappings, this, "mappings"); + this.mappings = ApiTypeHelper.unmodifiable(builder.mappings); this.mappingsPath = builder.mappingsPath; - } - public static MappingCharFilter of(Function> fn) { + public static MappingCharFilter of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * CharFilterDefinition variant kind. + * {@link CharFilterDefinition} variant kind. */ @Override public CharFilterDefinition.Kind _charFilterDefinitionKind() { @@ -76,8 +84,9 @@ public CharFilterDefinition.Kind _charFilterDefinitionKind() { } /** - * Required - API name: {@code mappings} + * API name: {@code mappings} */ + @Nonnull public final List mappings() { return this.mappings; } @@ -91,7 +100,6 @@ public final String mappingsPath() { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.write("type", "mapping"); super.serializeInternal(generator, mapper); if (ApiTypeHelper.isDefined(this.mappings)) { @@ -99,17 +107,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartArray(); for (String item0 : this.mappings) { generator.write(item0); - } generator.writeEnd(); - } + if (this.mappingsPath != null) { generator.writeKey("mappings_path"); generator.write(this.mappingsPath); - } - } // --------------------------------------------------------------------------------------------- @@ -117,17 +122,18 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link MappingCharFilter}. */ - public static class Builder extends CharFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private List mappings; - @Nullable private String mappingsPath; /** - * Required - API name: {@code mappings} + * API name: {@code mappings} + * *

* Adds all elements of list to mappings. + *

*/ public final Builder mappings(List list) { this.mappings = _listAddAll(this.mappings, list); @@ -135,9 +141,11 @@ public final Builder mappings(List list) { } /** - * Required - API name: {@code mappings} + * API name: {@code mappings} + * *

* Adds one or more values to mappings. + *

*/ public final Builder mappings(String value, String... values) { this.mappings = _listAdd(this.mappings, value, values); @@ -160,8 +168,7 @@ protected Builder self() { /** * Builds a {@link MappingCharFilter}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public MappingCharFilter build() { _checkSingleUse(); @@ -188,4 +195,22 @@ protected static void setupMappingCharFilterDeserializer(ObjectDeserializer> fn) { + public static PatternReplaceCharFilter of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * CharFilterDefinition variant kind. + * {@link CharFilterDefinition} variant kind. */ @Override public CharFilterDefinition.Kind _charFilterDefinitionKind() { @@ -88,6 +97,7 @@ public final String flags() { /** * Required - API name: {@code pattern} */ + @Nonnull public final String pattern() { return this.pattern; } @@ -95,14 +105,18 @@ public final String pattern() { /** * API name: {@code replacement} */ + @Nullable public final String replacement() { return this.replacement; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.write("type", "pattern_replace"); super.serializeInternal(generator, mapper); + if (this.flags != null) { + generator.writeKey("flags"); + generator.write(this.flags); + } generator.writeKey("pattern"); generator.write(this.pattern); @@ -111,11 +125,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("replacement"); generator.write(this.replacement); } - - if (this.flags != null) { - generator.writeKey("flags"); - generator.write(this.flags); - } } // --------------------------------------------------------------------------------------------- @@ -123,13 +132,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link PatternReplaceCharFilter}. */ - public static class Builder extends CharFilterBase.AbstractBuilder implements ObjectBuilder { @Nullable private String flags; - private String pattern; - @Nullable private String replacement; @@ -165,8 +171,7 @@ protected Builder self() { /** * Builds a {@link PatternReplaceCharFilter}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public PatternReplaceCharFilter build() { _checkSingleUse(); @@ -186,7 +191,7 @@ public PatternReplaceCharFilter build() { ); protected static void setupPatternReplaceCharFilterDeserializer(ObjectDeserializer op) { - CharFilterBase.setupCharFilterBaseDeserializer(op); + setupCharFilterBaseDeserializer(op); op.add(Builder::flags, JsonpDeserializer.stringDeserializer(), "flags"); op.add(Builder::pattern, JsonpDeserializer.stringDeserializer(), "pattern"); op.add(Builder::replacement, JsonpDeserializer.stringDeserializer(), "replacement"); @@ -194,4 +199,25 @@ protected static void setupPatternReplaceCharFilterDeserializer(ObjectDeserializ op.ignore("type"); } + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Objects.hashCode(this.flags); + result = 31 * result + this.pattern.hashCode(); + result = 31 * result + Objects.hashCode(this.replacement); + 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; + PatternReplaceCharFilter other = (PatternReplaceCharFilter) o; + return Objects.equals(this.flags, other.flags) + && this.pattern.equals(other.pattern) + && Objects.equals(this.replacement, other.replacement); + } } 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 0bec0ea470..464fad0519 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 @@ -33,6 +33,7 @@ private static JsonPointer schema(String namespace, String name) { .with(schema("_common", "StringifiedEpochTimeUnitMillis"), so -> so.withMappedType(Types.Primitive.Long)) .with(schema("_common.analysis", "Analyzer"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + .with(schema("_common.analysis", "CharFilter"), so -> so.withShouldGenerate(ShouldGenerate.Always)) .with(schema("_common.analysis", "TokenFilter"), so -> so.withShouldGenerate(ShouldGenerate.Always)) .with(schema("_common.analysis", "Tokenizer"), so -> so.withShouldGenerate(ShouldGenerate.Always))