Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] [2.x] add toBuilder method on some models (#766) #797

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading