Skip to content

Commit

Permalink
add toBuilder method on some models (opensearch-project#766)
Browse files Browse the repository at this point in the history
* add toQuery() on SearchRequest

Signed-off-by: channel-dante <dante@channel.io>

* add toBuilder() on all Request in org.opensearch.client.opensearch.core

Signed-off-by: channel-dante <dante@channel.io>

* add toBuilder() on all Builder in org.opensearch.client.opensearch._types.query_dsl

Signed-off-by: channel-dante <dante@channel.io>

* update CHANGELOG.md

Signed-off-by: channel-dante <dante@channel.io>

* apply spotlessApply

Signed-off-by: channel-dante <dante@channel.io>

* fix CommonTermsQuery.toBuilder()

Signed-off-by: channel-dante <dante@channel.io>

* fix FuzzyQuery.toBuilder()

Signed-off-by: channel-dante <dante@channel.io>

* fix toBuilders

Signed-off-by: channel-dante <dante@channel.io>

* add test for _types/query_dsl package

Signed-off-by: channel-dante <dante@channel.io>

* add test for core package

Signed-off-by: channel-dante <dante@channel.io>

* spotlessApply

Signed-off-by: channel-dante <dante@channel.io>

* fix test

Signed-off-by: channel-dante <dante@channel.io>

* revert ModelTestCase

Signed-off-by: channel-dante <dante@channel.io>

* revert ModelTestCase

Signed-off-by: channel-dante <dante@channel.io>

* add pr link on CHANGELOG.md

Signed-off-by: channel-dante <dante@channel.io>

* add pr link on CHANGELOG.md

Signed-off-by: channel-dante <dante@channel.io>

* apply spotless

Signed-off-by: channel-dante <dante@channel.io>

---------

Signed-off-by: channel-dante <dante@channel.io>

(cherry picked from commit a8fea24)
Signed-off-by: channel-dante <dante@channel.io>
  • Loading branch information
channel-dante committed Jan 3, 2024
1 parent 58416a5 commit 8c7f4c9
Show file tree
Hide file tree
Showing 234 changed files with 2,951 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added support for icu_collation_keyword type ([#725](https://github.com/opensearch-project/opensearch-java/pull/725))
- Added support for flat_object field property ([#735](https://github.com/opensearch-project/opensearch-java/pull/735))
- Expose HTTP status code through `ResponseException#status` ([#756](https://github.com/opensearch-project/opensearch-java/pull/756))
- Added toBuilder method to all request model in core package & _types.query_dsl package ([#766](https://github.com/opensearch-project/opensearch-java/pull/766))

### Dependencies
- Bumps `com.diffplug.spotless` from 6.22.0 to 6.23.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().filter(filter).minimumShouldMatch(minimumShouldMatch).must(must).mustNot(mustNot).should(should);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().negativeBoost(negativeBoost).negative(negative).positive(positive);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().fields(fields)
.query(query)
.autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery)
.operator(operator)
.mimimumShouldMatch(mimimumShouldMatch)
.zeroTermsQuery(zeroTermsQuery);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().field(field)
.analyzer(analyzer)
.cutoffFrequency(cutoffFrequency)
.highFreqOperator(highFreqOperator)
.lowFreqOperator(lowFreqOperator)
.minimumShouldMatch(minimumShouldMatch)
.query(query);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().filter(filter);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().field(field).placement(placement);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().decay(decay).offset(offset).scale(scale).origin(origin);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().queries(queries).tieBreaker(tieBreaker);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().origin(origin).pivot(pivot).field(field);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().field(field);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().field(field).format(format).includeUnmapped(includeUnmapped);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().id(id).index(index).path(path).routing(routing);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().field(field).factor(factor).missing(missing).modifier(modifier);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder()._kind(_kind)._value(_value).filter(filter).weight(weight);
}

public static class Builder extends ObjectBuilderBase {
private Kind _kind;
private Object _value;
Expand All @@ -285,6 +289,16 @@ public static class Builder extends ObjectBuilderBase {
@Nullable
private Double weight;

protected final Builder _kind(Kind v) {
this._kind = v;
return this;
}

protected final Builder _value(Object v) {
this._value = v;
return this;
}

/**
* API name: {@code filter}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().boostMode(boostMode)
.functions(functions)
.maxBoost(maxBoost)
.minScore(minScore)
.query(query)
.scoreMode(scoreMode);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().field(field)
.value(value)
.maxExpansions(maxExpansions)
.prefixLength(prefixLength)
.rewrite(rewrite)
.transpositions(transpositions)
.fuzziness(fuzziness)
.value(value);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().field(field)
.boundingBox(boundingBox)
.type(type)
.validationMethod(validationMethod)
.ignoreUnmapped(ignoreUnmapped);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().field(field).location(location);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().points(points);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().shape(shape).indexedShape(indexedShape).relation(relation);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().field(field).shape(shape);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().ignoreUnmapped(ignoreUnmapped)
.innerHits(innerHits)
.maxChildren(maxChildren)
.minChildren(minChildren)
.query(query)
.scoreMode(scoreMode)
.type(type);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().ignoreUnmapped(ignoreUnmapped).innerHits(innerHits).parentType(parentType).query(query).score(score);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().values(values);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,24 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder()._kind(_kind)._value(_value);
}

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<Intervals> {
private Kind _kind;
private Object _value;

protected final Builder _kind(Kind v) {
this._kind = v;
return this;
}

protected final Builder _value(Object v) {
this._value = v;
return this;
}

public ObjectBuilder<Intervals> allOf(IntervalsAllOf v) {
this._kind = Kind.AllOf;
this._value = v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().intervals(intervals).maxGaps(maxGaps).ordered(ordered).filter(filter);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder().intervals(intervals);
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,24 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {

}

public Builder toBuilder() {
return new Builder()._kind(_kind)._value(_value);
}

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<IntervalsFilter> {
private Kind _kind;
private Object _value;

protected final Builder _kind(Kind v) {
this._kind = v;
return this;
}

protected final Builder _value(Object v) {
this._value = v;
return this;
}

public ObjectBuilder<IntervalsFilter> after(Intervals v) {
this._kind = Kind.After;
this._value = v;
Expand Down
Loading

0 comments on commit 8c7f4c9

Please sign in to comment.