groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Laforge <glafo...@gmail.com>
Subject Re: Required named parameters in constructor?
Date Tue, 19 Apr 2016 08:47:56 GMT
There's actually the new MapConstructor AS transformation which we could
use here:
https://speakerdeck.com/glaforge/a-groovy-journey-in-open-source-greach-2016?slide=130
https://github.com/apache/groovy/blob/master/src/main/groovy/transform/MapConstructor.java

You'd define a pre-condition, checking that the required params are indeed
present.

Guillaume


On Tue, Apr 19, 2016 at 8:20 AM, Jochen Theodorou <blackdrag@gmx.org> wrote:

> On 19.04.2016 05:21, emmanuel r wrote:
>
>> You know, I bet that could be done with an ast transformation. Using it
>> could look like this:
>>
>> @RequiredConstructorParameters(parameters = ['a'])
>> class Foo {
>>      String a
>>      String b
>> }
>>
>
> well, you could try TupleConstructor for example
>
> be Jochen
>
>
>
>


-- 
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Product Ninja & Advocate at Restlet <http://restlet.com>

Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>

Mime
View raw message