|
|
|
|
|
by lliamander
3923 days ago
|
|
You can have a type-safe fluent Builder, but it requires having one or more static nested classes with private constructors. The outer class will not have a build() method, but rather that method will live in one of the nested classes. You use the type system to control what parameters have already been set, and what parameters need to be set. Obviously, this can apply to many sorts of fluent API. This is at least part of what Tony Morris is alluding to in his essay on API design [1]. [1] http://blog.tmorris.net/posts/understanding-practical-api-de... |
|