[cdi-dev] [JBoss JIRA] (CDI-475) Support type annotation in assignability of parameterized types

Jozef Hartinger (JIRA) issues at jboss.org
Fri Oct 3 09:05:11 EDT 2014


    [ https://issues.jboss.org/browse/CDI-475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13008497#comment-13008497 ] 

Jozef Hartinger commented on CDI-475:
-------------------------------------

How is this different from CDI-472?

> Support type annotation in assignability of parameterized types
> ---------------------------------------------------------------
>
>                 Key: CDI-475
>                 URL: https://issues.jboss.org/browse/CDI-475
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Resolution
>            Reporter: Antonin Stefanutti
>
> Since Java 8 provides support for type annotations, the assignability of parameterized types rules could be updated to support that feature that may add value in a number of use cases.
> For example, with lifecycle events resolution, instead of writing:
> {code}
> Set<Annotation> contextNames = new HashSet<>();
> void camelContextNames(@Observes ProcessAnnotatedType<? extends CamelContext> pat) {
>     if (pat.getAnnotatedType().isAnnotationPresent(ContextName.class))
>         contextNames.add(pat.getAnnotatedType().getAnnotation(ContextName.class));
> }
> {code}
> One could directly write:
> {code}
> void camelContextNames(@Observes ProcessAnnotatedType<@ContextName ? extends CamelContext> pat) {
>     contextNames.add(pat.getAnnotatedType().getAnnotation(ContextName.class));
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.1#6329)


More information about the cdi-dev mailing list