groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-7087) @TupleConstructor and @Builder should be able to use defined setters rather than the field directly
Date Mon, 03 Apr 2017 07:56:42 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-7087?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Paul King updated GROOVY-7087:
------------------------------
    Summary: @TupleConstructor and @Builder should be able to use defined setters rather than
the field directly  (was: @TupleConstructor and @Builder should use defined setters rather
than the field directly)

> @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)

Mime
View raw message