golo-lang icon indicating copy to clipboard operation
golo-lang copied to clipboard

Generalize Fluent Methods

Open yloiseau opened this issue 8 years ago • 2 comments

Currently, setters, e.g. void setFoo(Object v), can be called as builder properties, as if the method ThisObject foo(Object v) were defined, thus allowing a fluent chaining of setter methods (behavior defined here).

I think it could be useful to extends this behavior to any method returning void.

yloiseau avatar May 04 '17 08:05 yloiseau

With a fallback behavior this feature could be explicit.

We could define a Fluent behavior with an augmentationon on the java.lang.Object. The user would be responsible to import the feature if he wants to use it. If the user defines its own fluent method it will use instead of the fallback behavior.

Thougts?

danielpetisme avatar May 09 '17 10:05 danielpetisme

@danielpetisme What I propose is just to wrap methods returning void to return the object itself. Fallback is of no use here, since the method exists, and thus doesn't trigger the behavior.

yloiseau avatar May 10 '17 08:05 yloiseau