[ 
https://issues.apache.org/jira/browse/GROOVY-10621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17536205#comment-17536205
 ] 

Eric Milles edited comment on GROOVY-10621 at 5/12/22 4:06 PM:
---------------------------------------------------------------

Just to recap now that I'm at a keyboard, you can write your type this way:
{code:groovy}
class CheckoutVoucherDTO  implements ... {
    Boolean restrictToPayer
}
{code}

This will give you "dto.restrictToPayer" and "dto.getRestrictToPayer()" 
resolution.

Or you can write like this:
{code:groovy}
class CheckoutVoucherDTO  implements ... {
    private Boolean restrictToPayer
    boolean isRestrictToPayer() {
        restrictToPayer
    }
    void setRestrictToPayer(Boolean value) {
        restrictToPayer = value
    }
}
{code}

This will give you "dto.restrictToPayer" and "dto.isRestrictToPayer()" 
resolution.

Not sure if the tri-state logic of the field is required for anything specific.


was (Author: emilles):
Just to recap now that I'm at a keyboard, you can write your type this way:
{code:groovy}
class CheckoutVoucherDTO  implements ... {
    Boolean restrictToPayer
}
{code}

This will give you "dto.restrictToPayer" and "dto.getRestrictToPayer()" 
resolution.

Or you can write like this:
{code:groovy}
class CheckoutVoucherDTO  implements ... {
    private Boolean restrictToPayer
    boolean isRestrictToPlayer() {
        restrictToPayer
    }
    void setRestrictToPayer(Boolean value) {
        restrictToPayer = value
    }
}
{code}

This will give you "dto.restrictToPayer" and "dto.isRestrictToPayer()" 
resolution.

Not sure if the tri-state logic of the field is required for anything specific.

> Why isAttribute style getters have gone from groovy 4
> -----------------------------------------------------
>
>                 Key: GROOVY-10621
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10621
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Dmitry
>            Priority: Blocker
>
> I use groovy 2.5.15 and try 3 version groovy - isAttribute style getters work 
> correct.
> But when I upgrade groovy for 4 version - isAttribute style getters are 
> disappeared.
> I has auto-genereted class:
>  
> {code:java}
> class CheckoutVoucherDTO  implements _DTOTrait, CheckoutVoucherDTOTrait {
>     private Boolean restrictToPayer = null
>     Boolean isRestrictToPayer() {
>         return restrictToPayer
>     }
>     void setRestrictToPayer(Boolean restrictToPayer) {
>         this.restrictToPayer = restrictToPayer
>     }
> } {code}
>  
>  
> And use:
>  
> {code:java}
> if (dto.restrictToPayer) {
>    //logic
> } {code}
> But in groovy 4 I catch exception: "Access to 
> ish.oncourse.server.api.v1.model.CheckoutVoucherDTO#restrictToPayer is 
> forbidden"
> When I add method: 
>  
> {code:java}
> Boolean getRestrictToPayer() { return restrictToPayer } {code}
> it work. But I has 2 nuances:
>  
>  # It is auto-genereted code and it is use in another not only groovy but in 
> java classes too.
>  # I has a lot of places using isAttribute syntax and it is impossible to 
> rewrite all with dto.isRestrictToPayer() 
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to