mkarneim / pojobuilder

A Java Code Generator for Pojo Builders
Other
334 stars 44 forks source link

Add the possibilty to generate buildTo(T aRef) method via configuration on annotation for instance #131

Closed alexandrenavarro closed 7 years ago

alexandrenavarro commented 7 years ago

Add the possibilty to generate buildTo(T aRef) method via configuration on annotation for instance.

The method is very close to what to build method but you can pass a parameter to keep the object

T buildTo(T arg) { arg = build(); return arg; }

This method is useful when you use builders when you create UI component to keep a reference on without quitting the fluent way to set the different informations in the builder.

alexandrenavarro commented 7 years ago

After reflection, I will do some custom stuffs with withGenerationGap. It is not so natural as I though because of the reference is passed as value, I need more like a Reference like AtomicReference, I will close the issue. Thanks for your lib, it is very useful and works like a charm.