Skip to content

Commit

Permalink
Generate Normalizer variants
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Nov 12, 2024
1 parent 14d27fd commit 017f2a1
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,54 @@
* 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;
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;

// typedef: _types.analysis.CustomNormalizer

@JsonpDeserializable
public class CustomNormalizer implements NormalizerVariant, JsonpSerializable {
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class CustomNormalizer implements NormalizerVariant, PlainJsonSerializable {

@Nonnull
private final List<String> charFilter;

@Nonnull
private final List<String> filter;

// ---------------------------------------------------------------------------------------------

private CustomNormalizer(Builder builder) {

this.charFilter = ApiTypeHelper.unmodifiable(builder.charFilter);
this.filter = ApiTypeHelper.unmodifiable(builder.filter);

}

public static CustomNormalizer of(Function<Builder, ObjectBuilder<CustomNormalizer>> fn) {
public static CustomNormalizer of(Function<CustomNormalizer.Builder, ObjectBuilder<CustomNormalizer>> fn) {
return fn.apply(new Builder()).build();
}

/**
* Normalizer variant kind.
* {@link Normalizer} variant kind.
*/
@Override
public Normalizer.Kind _normalizerKind() {
Expand All @@ -78,70 +87,67 @@ public Normalizer.Kind _normalizerKind() {
/**
* API name: {@code char_filter}
*/
@Nonnull
public final List<String> charFilter() {
return this.charFilter;
}

/**
* API name: {@code filter}
*/
@Nonnull
public final List<String> filter() {
return this.filter;
}

/**
* Serialize this object to JSON.
*/
@Override
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.write("type", "custom");

if (ApiTypeHelper.isDefined(this.charFilter)) {
generator.writeKey("char_filter");
generator.writeStartArray();
for (String item0 : this.charFilter) {
generator.write(item0);

}
generator.writeEnd();

}

if (ApiTypeHelper.isDefined(this.filter)) {
generator.writeKey("filter");
generator.writeStartArray();
for (String item0 : this.filter) {
generator.write(item0);

}
generator.writeEnd();

}

}

// ---------------------------------------------------------------------------------------------

/**
* Builder for {@link CustomNormalizer}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<CustomNormalizer> {
@Nullable
private List<String> charFilter;

@Nullable
private List<String> filter;

/**
* API name: {@code char_filter}
*
* <p>
* Adds all elements of <code>list</code> to <code>charFilter</code>.
* </p>
*/
public final Builder charFilter(List<String> list) {
this.charFilter = _listAddAll(this.charFilter, list);
Expand All @@ -150,8 +156,10 @@ public final Builder charFilter(List<String> list) {

/**
* API name: {@code char_filter}
*
* <p>
* Adds one or more values to <code>charFilter</code>.
* </p>
*/
public final Builder charFilter(String value, String... values) {
this.charFilter = _listAdd(this.charFilter, value, values);
Expand All @@ -160,8 +168,10 @@ public final Builder charFilter(String value, String... values) {

/**
* API name: {@code filter}
*
* <p>
* Adds all elements of <code>list</code> to <code>filter</code>.
* </p>
*/
public final Builder filter(List<String> list) {
this.filter = _listAddAll(this.filter, list);
Expand All @@ -170,8 +180,10 @@ public final Builder filter(List<String> list) {

/**
* API name: {@code filter}
*
* <p>
* Adds one or more values to <code>filter</code>.
* </p>
*/
public final Builder filter(String value, String... values) {
this.filter = _listAdd(this.filter, value, values);
Expand All @@ -181,8 +193,7 @@ public final Builder filter(String value, String... values) {
/**
* Builds a {@link CustomNormalizer}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
public CustomNormalizer build() {
_checkSingleUse();
Expand All @@ -202,11 +213,25 @@ public CustomNormalizer build() {
);

protected static void setupCustomNormalizerDeserializer(ObjectDeserializer<CustomNormalizer.Builder> op) {

op.add(Builder::charFilter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "char_filter");
op.add(Builder::filter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "filter");

op.ignore("type");
}

@Override
public int hashCode() {
int result = 17;
result = 31 * result + Objects.hashCode(this.charFilter);
result = 31 * result + Objects.hashCode(this.filter);
return result;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
CustomNormalizer other = (CustomNormalizer) o;
return Objects.equals(this.charFilter, other.charFilter) && Objects.equals(this.filter, other.filter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,40 @@
* 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;
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.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;

// typedef: _types.analysis.LowercaseNormalizer

@JsonpDeserializable
public class LowercaseNormalizer implements NormalizerVariant, JsonpSerializable {
// ---------------------------------------------------------------------------------------------
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class LowercaseNormalizer implements NormalizerVariant, PlainJsonSerializable {

private LowercaseNormalizer(Builder builder) {
// ---------------------------------------------------------------------------------------------

}
private LowercaseNormalizer(Builder builder) {}

public static LowercaseNormalizer of(Function<Builder, ObjectBuilder<LowercaseNormalizer>> fn) {
public static LowercaseNormalizer of(Function<LowercaseNormalizer.Builder, ObjectBuilder<LowercaseNormalizer>> fn) {
return fn.apply(new Builder()).build();
}

/**
* Normalizer variant kind.
* {@link Normalizer} variant kind.
*/
@Override
public Normalizer.Kind _normalizerKind() {
Expand All @@ -68,31 +73,28 @@ public Normalizer.Kind _normalizerKind() {
/**
* Serialize this object to JSON.
*/
@Override
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.write("type", "lowercase");

}

// ---------------------------------------------------------------------------------------------

/**
* Builder for {@link LowercaseNormalizer}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<LowercaseNormalizer> {

/**
* Builds a {@link LowercaseNormalizer}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
public LowercaseNormalizer build() {
_checkSingleUse();
Expand All @@ -116,4 +118,16 @@ protected static void setupLowercaseNormalizerDeserializer(ObjectDeserializer<Lo
op.ignore("type");
}

@Override
public int hashCode() {
int result = 17;
return result;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
return true;
}
}
Loading

0 comments on commit 017f2a1

Please sign in to comment.