Given the following annotation type declaration in Java:
public @interface Timeout {
int value();
TimeUnit unit();
}
In Java I can write:
@Timeout(5, unit = TimeUnit.SECONDS)
The Groovy equivalent is slightly more verbose
:
@Timeout(value = 5, unit = TimeUnit.SECONDS)
Groovy should also allow the former style.
Additionally, Jochen has suggested to allow the following styles (see http://www.nabble.com/Annotation-syntax%3A-Java-vs.-Groovy-to17217160.html):
@Timeout(5, unit: TimeUnit.SECONDS)
@Timeout(value: 5, unit: TimeUnit.SECONDS)
> On Wed, May 14, 2008 at 12:06 PM, Jochen Theodorou <blackdrag@gmx.org> wrote:
>> Dierk König schrieb:
>>> | @Timeout(value:5, unit:TimeUnit.SECONDS)
>>> | | and of course this:
>>> | | @Timeout(5, unit:TimeUnit.SECONDS)
>>>
>>> and it would be typically Groovy to also allow
>>>
@Timeout value:5, unit:TimeUnit.SECONDS
>> hehe, very true.. how about filling an issue for this too?
>
> Can there be an ambiguity when annotations are nested inside annotations?
in that case you have to use (), it is the same as with method calls inside method calls
bye blackdrag