Ah! this has a name: "Curiously Recurring Generics" (or "Curiously Recurring 
Template" from C++).

This allows us to declare builder methods in the interface that return an 
instance of whatever subclass was used to invoke the method. Such as `BC 
bufferKeys(final long maxKeys)`. When we call this on an Eager config, we get 
back an Eager config, and when we call it on a Strict config, we get back a 
Strict config.

If you recall the weird comment in Windows that says "all subclasses should 
override this method so they can return the correct type", we were looking for 
the same property. If we had used this pattern, we wouldn't have needed that 
comment, as the overridden methods would automatically take on the correct 
return type.

[ Full content available at: https://github.com/apache/kafka/pull/5567 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to