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

Paul King commented on GROOVY-8889:
-----------------------------------

This is a 2.5.5+ feature.

> @NamedParam(required=true) is not enforced
> ------------------------------------------
>
>                 Key: GROOVY-8889
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8889
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.4
>            Reporter: VladimĂ­r OranĂ˝
>            Priority: Major
>
> in following snipped the required parameter is not enforced at all:
> {code}
> import groovy.transform.CompileStatic
> import groovy.transform.NamedParam
> import groovy.transform.NamedParams
> @CompileStatic
> class Tester {
>     String text
>     String color
>     static Tester note(String text, String color) {
>         return new Tester(text: text, color: color)
>     }
> }
> @CompileStatic
> class TesterBuilder {
>     static Tester note(
>             @NamedParams([
>                     @NamedParam(value = 'text', type = String, required = 
> true),
>                     @NamedParam(value = 'color', type = String)
>             ])
>             Map<String, String> params
>     ) {
>         return Tester.note(params.text, params.color)
>     }
> }
> @CompileStatic
> Tester useBuilder() {
>     return TesterBuilder.note(color: 'blue')
> }
> useBuilder()
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to