-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
QueryBuilder does not need generics. #18133
Conversation
@@ -50,7 +50,7 @@ | |||
/** | |||
* Sets the arbitrary name to be assigned to the query (see named queries). | |||
*/ | |||
QB queryName(String queryName); | |||
QueryBuilder queryName(String queryName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why it had the generics. OTOH I'll bet if we always return the subclass of QueryBuilder anyplace interesting and have each of them implement this method by returning their own type then no client code will have to change. We should probably add something to the docs on this method telling implementers to return their own type, not QueryBuilder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works fine in practice because query builders are always constructed with their concrete type. With this pull request already, none of the client code that we had in the test folders had to change.
I will add the note to the javadocs of QueryBuilder (pointing out that extending AbstractQueryBuilder does it for you).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extending AbstractQueryBuilder does it for you
Awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed one more commit with docs.
I felt a great disturbance in the Force, as if hundreds of spurious warnings suddenly cried out in terror, and were suddenly silenced. I fear something awesome has happened. |
LGTM |
QueryBuilder has generics, but those are never used: all call sites use `QueryBuilder<?>`. Only `AbstractQueryBuilder` needs generics so that the base class can contain a default implementation for setters that returns `this`.
35ab316
to
7d87087
Compare
…lastic#18368 Similar reasoning as elastic#18133 but for the aggs API. One important change is that I moved the base PipelineAggregatorBuilder class to the o.e.s.aggregations package instead of o.e.s.aggregations.pipeline so that the create method does not need to be public.
QueryBuilder has generics, but those are never used: all call sites use
QueryBuilder<?>
. OnlyAbstractQueryBuilder
needs generics so that the baseclass can contain a default implementation for setters that returns
this
.