Skip to content

Commit

Permalink
Generate Analyzer 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 9df0451 commit c55b24f
Show file tree
Hide file tree
Showing 23 changed files with 941 additions and 601 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,65 +30,72 @@
* 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 Analyzer} variants.
*/
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class AnalyzerBuilders {
private AnalyzerBuilders() {}

/**
* Creates a builder for the {@link CustomAnalyzer custom} {@code Analyzer}
* variant.
* Creates a builder for the {@link CjkAnalyzer cjk} {@code Analyzer} variant.
*/
public static CjkAnalyzer.Builder cjk() {
return new CjkAnalyzer.Builder();
}

/**
* Creates a builder for the {@link CustomAnalyzer custom} {@code Analyzer} variant.
*/
public static CustomAnalyzer.Builder custom() {
return new CustomAnalyzer.Builder();
}

/**
* Creates a builder for the {@link DutchAnalyzer dutch} {@code Analyzer}
* variant.
* Creates a builder for the {@link DutchAnalyzer dutch} {@code Analyzer} variant.
*/
public static DutchAnalyzer.Builder dutch() {
return new DutchAnalyzer.Builder();
}

/**
* Creates a builder for the {@link FingerprintAnalyzer fingerprint}
* {@code Analyzer} variant.
* Creates a builder for the {@link FingerprintAnalyzer fingerprint} {@code Analyzer} variant.
*/
public static FingerprintAnalyzer.Builder fingerprint() {
return new FingerprintAnalyzer.Builder();
}

/**
* Creates a builder for the {@link IcuAnalyzer icu_analyzer} {@code Analyzer}
* variant.
* Creates a builder for the {@link IcuAnalyzer icu_analyzer} {@code Analyzer} variant.
*/
public static IcuAnalyzer.Builder icuAnalyzer() {
return new IcuAnalyzer.Builder();
}

/**
* Creates a builder for the {@link KeywordAnalyzer keyword} {@code Analyzer}
* variant.
* Creates a builder for the {@link KeywordAnalyzer keyword} {@code Analyzer} variant.
*/
public static KeywordAnalyzer.Builder keyword() {
return new KeywordAnalyzer.Builder();
}

/**
* Creates a builder for the {@link KuromojiAnalyzer kuromoji} {@code Analyzer}
* variant.
* Creates a builder for the {@link KuromojiAnalyzer kuromoji} {@code Analyzer} variant.
*/
public static KuromojiAnalyzer.Builder kuromoji() {
return new KuromojiAnalyzer.Builder();
}

/**
* Creates a builder for the {@link LanguageAnalyzer language} {@code Analyzer}
* variant.
* Creates a builder for the {@link LanguageAnalyzer language} {@code Analyzer} variant.
*/
public static LanguageAnalyzer.Builder language() {
return new LanguageAnalyzer.Builder();
Expand All @@ -102,32 +109,35 @@ public static NoriAnalyzer.Builder nori() {
}

/**
* Creates a builder for the {@link PatternAnalyzer pattern} {@code Analyzer}
* variant.
* Creates a builder for the {@link PatternAnalyzer pattern} {@code Analyzer} variant.
*/
public static PatternAnalyzer.Builder pattern() {
return new PatternAnalyzer.Builder();
}

/**
* Creates a builder for the {@link SimpleAnalyzer simple} {@code Analyzer}
* variant.
* Creates a builder for the {@link SimpleAnalyzer simple} {@code Analyzer} variant.
*/
public static SimpleAnalyzer.Builder simple() {
return new SimpleAnalyzer.Builder();
}

/**
* Creates a builder for the {@link SnowballAnalyzer snowball} {@code Analyzer}
* variant.
* Creates a builder for the {@link SmartcnAnalyzer smartcn} {@code Analyzer} variant.
*/
public static SmartcnAnalyzer.Builder smartcn() {
return new SmartcnAnalyzer.Builder();
}

/**
* Creates a builder for the {@link SnowballAnalyzer snowball} {@code Analyzer} variant.
*/
public static SnowballAnalyzer.Builder snowball() {
return new SnowballAnalyzer.Builder();
}

/**
* Creates a builder for the {@link StandardAnalyzer standard} {@code Analyzer}
* variant.
* Creates a builder for the {@link StandardAnalyzer standard} {@code Analyzer} variant.
*/
public static StandardAnalyzer.Builder standard() {
return new StandardAnalyzer.Builder();
Expand All @@ -141,11 +151,9 @@ public static StopAnalyzer.Builder stop() {
}

/**
* Creates a builder for the {@link WhitespaceAnalyzer whitespace}
* {@code Analyzer} variant.
* Creates a builder for the {@link WhitespaceAnalyzer whitespace} {@code Analyzer} variant.
*/
public static WhitespaceAnalyzer.Builder whitespace() {
return new WhitespaceAnalyzer.Builder();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,23 @@
* 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.JsonpSerializable;

/**
* Base interface for {@link Analyzer} variants.
*/
@Generated("org.opensearch.client.codegen.CodeGenerator")
public interface AnalyzerVariant extends JsonpSerializable {

Analyzer.Kind _analyzerKind();

default Analyzer _toAnalyzer() {
return new Analyzer(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,36 @@
* compatible open source license.
*/

//----------------------------------------------------
// 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.LanguageAnalyzer
// typedef: _types.analysis.CjkAnalyzer

@JsonpDeserializable
public class CjkAnalyzer implements AnalyzerVariant, JsonpSerializable {
@Nullable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class CjkAnalyzer implements AnalyzerVariant, PlainJsonSerializable {

@Nonnull
private final List<String> stopwords;

@Nullable
Expand All @@ -35,18 +44,16 @@ public class CjkAnalyzer implements AnalyzerVariant, JsonpSerializable {
// ---------------------------------------------------------------------------------------------

private CjkAnalyzer(Builder builder) {

this.stopwords = ApiTypeHelper.unmodifiable(builder.stopwords);
this.stopwordsPath = builder.stopwordsPath;

}

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

/**
* Analyzer variant kind.
* {@link Analyzer} variant kind.
*/
@Override
public Analyzer.Kind _analyzerKind() {
Expand All @@ -56,6 +63,7 @@ public Analyzer.Kind _analyzerKind() {
/**
* API name: {@code stopwords}
*/
@Nonnull
public final List<String> stopwords() {
return this.stopwords;
}
Expand All @@ -71,51 +79,47 @@ public final String stopwordsPath() {
/**
* 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", Analyzer.Kind.Cjk.jsonValue());

generator.write("type", "cjk");
if (ApiTypeHelper.isDefined(this.stopwords)) {
generator.writeKey("stopwords");
generator.writeStartArray();
for (String item0 : this.stopwords) {
generator.write(item0);

}
generator.writeEnd();

}

if (this.stopwordsPath != null) {
generator.writeKey("stopwords_path");
generator.write(this.stopwordsPath);

}

}

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

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

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

@Nullable
private String stopwordsPath;

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

/**
* API name: {@code stopwords}
*
* <p>
* Adds one or more values to <code>stopwords</code>.
* </p>
*/
public final Builder stopwords(String value, String... values) {
this.stopwords = _listAdd(this.stopwords, value, values);
Expand All @@ -143,8 +149,7 @@ public final Builder stopwordsPath(@Nullable String value) {
/**
* Builds a {@link CjkAnalyzer}.
*
* @throws NullPointerException
* if some required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
public CjkAnalyzer build() {
_checkSingleUse();
Expand All @@ -160,15 +165,29 @@ public CjkAnalyzer build() {
*/
public static final JsonpDeserializer<CjkAnalyzer> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
Builder::new,
CjkAnalyzer::setupLanguageAnalyzerDeserializer
CjkAnalyzer::setupCjkAnalyzerDeserializer
);

protected static void setupLanguageAnalyzerDeserializer(ObjectDeserializer<CjkAnalyzer.Builder> op) {

protected static void setupCjkAnalyzerDeserializer(ObjectDeserializer<CjkAnalyzer.Builder> op) {
op.add(Builder::stopwords, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stopwords");
op.add(Builder::stopwordsPath, JsonpDeserializer.stringDeserializer(), "stopwords_path");

op.ignore("type");
}

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

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
CjkAnalyzer other = (CjkAnalyzer) o;
return Objects.equals(this.stopwords, other.stopwords) && Objects.equals(this.stopwordsPath, other.stopwordsPath);
}
}
Loading

0 comments on commit c55b24f

Please sign in to comment.