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 2016/04/22 12:20:12 UTC
[jira] [Updated] (GROOVY-7814) Consider allowing Groovy to support
Arrays of arbitrary annotations as the return type of an annotation
definition member
[ https://issues.apache.org/jira/browse/GROOVY-7814?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-7814:
------------------------------
Description:
This feature suggestion is proposing to extend the allowable return types for members in annotation definitions.
{code}
import java.lang.annotation.*
@Retention(RetentionPolicy.RUNTIME)
@Target([ElementType.TYPE])
@interface AnyAnnotationCollection {
Annotation[] value()
}
{code}
In this example, Java would require a specific annotation class instead of just {{Annotation}}.
Usage of the above annotation definition would look like:
{code}
@AnyAnnotationCollection([
@Grab('foo:bar:1.0'),
@AnyAnnotationCollection([
@FunctionalInterface,
@Deprecated
])
])
class Dummy{}
assert Dummy.annotations[0].value().size() == 2
assert Dummy.annotations[0].value()[1].value()[0].annotationType().simpleName == 'FunctionalInterface'
{code}
The nesting here is not in any way required but supported.
> Consider allowing Groovy to support Arrays of arbitrary annotations as the return type of an annotation definition member
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-7814
> URL: https://issues.apache.org/jira/browse/GROOVY-7814
> Project: Groovy
> Issue Type: New Feature
> Reporter: Paul King
> Assignee: Paul King
>
> This feature suggestion is proposing to extend the allowable return types for members in annotation definitions.
> {code}
> import java.lang.annotation.*
> @Retention(RetentionPolicy.RUNTIME)
> @Target([ElementType.TYPE])
> @interface AnyAnnotationCollection {
> Annotation[] value()
> }
> {code}
> In this example, Java would require a specific annotation class instead of just {{Annotation}}.
> Usage of the above annotation definition would look like:
> {code}
> @AnyAnnotationCollection([
> @Grab('foo:bar:1.0'),
> @AnyAnnotationCollection([
> @FunctionalInterface,
> @Deprecated
> ])
> ])
> class Dummy{}
> assert Dummy.annotations[0].value().size() == 2
> assert Dummy.annotations[0].value()[1].value()[0].annotationType().simpleName == 'FunctionalInterface'
> {code}
> The nesting here is not in any way required but supported.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)