You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/05/02 02:04:20 UTC
[jira] [Closed] (GROOVY-7087) @TupleConstructor and @Builder should
be able to use defined setters rather than the field directly
[ https://issues.apache.org/jira/browse/GROOVY-7087?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-7087.
-----------------------------
> @TupleConstructor and @Builder should be able to use defined setters rather than the field directly
> ---------------------------------------------------------------------------------------------------
>
> Key: GROOVY-7087
> URL: https://issues.apache.org/jira/browse/GROOVY-7087
> Project: Groovy
> Issue Type: Bug
> Components: xforms
> Affects Versions: 2.3.6
> Reporter: Pavel
> Assignee: Paul King
> Fix For: 2.5.0-alpha-1
>
>
> {code}
> import groovy.transform.TupleConstructor
> import groovy.transform.ToString
> import groovy.transform.InheritConstructors
> import groovy.transform.builder.Builder
> import groovy.transform.builder.SimpleStrategy
> @Builder(builderStrategy=SimpleStrategy, prefix='with')
> @TupleConstructor
> @ToString
> class Person{
> String name;
> void setName(String n){
> println "Called setName(n=$n)"
> name = n;
> }
> }
> println Person.constructors
> println ( [ new Person(name: 'Map style'), new Person('@TupleConsructor'), new Person().with{ name = 'With style'; it }, new Person().withName('@Builder') ] )
> {code}
> In output we get:
> {noformat}
> Called setName(n=Map style)
> Called setName(n=With style)
> [Person(Map style), Person(@TupleConsructor), Person(With style), Person(@Builder)]
> {noformat}
> So, all forms of new object instatiation like Map-style, With block became different with new methods, defined by AST transformations.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)