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

add toBuilder method on some models #766

Merged
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ This section is for maintaining a changelog for all breaking changes for the cli
- 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))
- Added toQuery method in Query and QueryVariant ([#760](https://github.com/opensearch-project/opensearch-java/pull/760)
- 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

### Changed
- Restore support for Java 8 ([#767](https://github.com/opensearch-project/opensearch-java/pull/767))

### Deprecated
- Deprecated "_toQuery()" in Query and QueryVariant ([#760](https://github.com/opensearch-project/opensearch-java/pull/760)

### Removed

### Fixed
Expand Down Expand Up @@ -258,4 +261,4 @@ This section is for maintaining a changelog for all breaking changes for the cli
[2.5.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.4.0...v2.5.0
[2.4.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.3.0...v2.4.0
[2.3.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.2.0...v2.3.0
[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0
[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0
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
Loading
Loading