Skip to content

Commit

Permalink
Added toBuilder to QueryBase instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
PiSoup committed Sep 3, 2024
1 parent 1ad7a6c commit e16bf93
Show file tree
Hide file tree
Showing 55 changed files with 58 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.filter(filter)
.minimumShouldMatch(minimumShouldMatch)
.must(must)
.mustNot(mustNot)
.should(should);
return toBuilder(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 @@ -111,7 +111,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.fields(fields)
return toBuilder(new Builder()).fields(fields)
.query(query)
.autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery)
.operator(operator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
return toBuilder(new Builder()).field(field)
.analyzer(analyzer)
.cutoffFrequency(cutoffFrequency)
.highFreqOperator(highFreqOperator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

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

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

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

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

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.boostMode(boostMode)
return toBuilder(new Builder()).boostMode(boostMode)
.functions(functions)
.maxBoost(maxBoost)
.minScore(minScore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
return toBuilder(new Builder()).field(field)
.value(value)
.maxExpansions(maxExpansions)
.prefixLength(prefixLength)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
return toBuilder(new Builder()).field(field)
.boundingBox(boundingBox)
.type(type)
.validationMethod(validationMethod)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.ignoreUnmapped(ignoreUnmapped)
return toBuilder(new Builder()).ignoreUnmapped(ignoreUnmapped)
.innerHits(innerHits)
.maxChildren(maxChildren)
.minChildren(minChildren)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.ignoreUnmapped(ignoreUnmapped)
return toBuilder(new Builder()).ignoreUnmapped(ignoreUnmapped)
.innerHits(innerHits)
.parentType(parentType)
.query(query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Query.Kind _queryKind() {
}

public HybridQuery.Builder toBuilder() {
return new HybridQuery.Builder().queryName(queryName()).boost(boost()).queries(queries);
return toBuilder(new Builder()).queries(queries);
}

public static class Builder extends QueryBase.AbstractBuilder<HybridQuery.Builder> implements ObjectBuilder<HybridQuery> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
}

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

public static class Builder extends QueryBase.AbstractBuilder<Builder> implements ObjectBuilder<IntervalsQuery> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName()).boost(boost()).field(field).vector(vector).k(k).filter(filter);
return toBuilder(new Builder()).field(field).vector(vector).k(k).filter(filter);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
return toBuilder(new Builder()).field(field)
.analyzer(analyzer)
.fuzziness(fuzziness)
.fuzzyRewrite(fuzzyRewrite)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
return toBuilder(new Builder()).field(field)
.analyzer(analyzer)
.maxExpansions(maxExpansions)
.query(query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
.analyzer(analyzer)
.query(query)
.slop(slop)
.zeroTermsQuery(zeroTermsQuery);
return toBuilder(new Builder()).field(field).analyzer(analyzer).query(query).slop(slop).zeroTermsQuery(zeroTermsQuery);
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
return toBuilder(new Builder()).field(field)
.analyzer(analyzer)
.autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery)
.cutoffFrequency(cutoffFrequency)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.analyzer(analyzer)
return toBuilder(new Builder()).analyzer(analyzer)
.boostTerms(boostTerms)
.failOnUnsupportedField(failOnUnsupportedField)
.fields(fields)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.analyzer(analyzer)
return toBuilder(new Builder()).analyzer(analyzer)
.autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery)
.cutoffFrequency(cutoffFrequency)
.fields(fields)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.ignoreUnmapped(ignoreUnmapped)
.innerHits(innerHits)
.path(path)
.query(query)
.scoreMode(scoreMode);
return toBuilder(new Builder()).ignoreUnmapped(ignoreUnmapped).innerHits(innerHits).path(path).query(query).scoreMode(scoreMode);
}

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

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
.queryText(queryText)
.queryImage(queryImage)
.k(k)
.modelId(modelId)
.filter(filter);
return toBuilder(new Builder()).field(field).queryText(queryText).queryImage(queryImage).k(k).modelId(modelId).filter(filter);
}

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

public Builder toBuilder() {
return new Builder().queryName(queryName()).boost(boost()).id(id).ignoreUnmapped(ignoreUnmapped).type(type);
return toBuilder(new Builder()).id(id).ignoreUnmapped(ignoreUnmapped).type(type);
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.document(document)
return toBuilder(new Builder()).document(document)
.documents(documents)
.field(field)
.id(id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
}

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

public static class Builder extends QueryBase.AbstractBuilder<Builder> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
.value(value)
.rewrite(rewrite)
.value(value)
.caseInsensitive(caseInsensitive);
return toBuilder(new Builder()).field(field).value(value).rewrite(rewrite).value(value).caseInsensitive(caseInsensitive);
}

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

}

protected <BuilderT extends AbstractBuilder<BuilderT>> BuilderT toBuilder(BuilderT builder) {
return builder.queryName(queryName).boost(boost);
}

protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends ObjectBuilderBase {
@Nullable
private Float boost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.allowLeadingWildcard(allowLeadingWildcard)
return toBuilder(new Builder()).allowLeadingWildcard(allowLeadingWildcard)
.analyzer(analyzer)
.analyzeWildcard(analyzeWildcard)
.autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
.gt(gt)
.gte(gte)
.lt(lt)
.lte(lte)
.from(from)
.to(to)
.format(format)
.timeZone(timeZone);
return toBuilder(new Builder()).field(field).gt(gt).gte(gte).lt(lt).lte(lte).from(from).to(to).format(format).timeZone(timeZone);
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}

public Builder toBuilder() {
return new Builder().queryName(queryName())
.boost(boost())
.field(field)
.saturation(saturation)
.log(log)
.linear(linear)
.sigmoid(sigmoid);
return toBuilder(new Builder()).field(field).saturation(saturation).log(log).linear(linear).sigmoid(sigmoid);
}

// ---------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit e16bf93

Please sign in to comment.