[seam-issues] [JBoss JIRA] Moved: (SOLDER-23) Provide utility to extract type parameter from Instance

Pete Muir (JIRA) jira-events at lists.jboss.org
Mon Nov 29 05:17:14 EST 2010

     [ https://jira.jboss.org/browse/SOLDER-23?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pete Muir moved WELDX-189 to SOLDER-23:

              Project: Seam Solder  (was: Weld Extensions)
                  Key: SOLDER-23  (was: WELDX-189)
    Affects Version/s:     (was: 1.0.0.Beta1)
        Fix Version/s: 1.0.0.Beta2
                           (was: 1.0.0.Beta2)

> Provide utility to extract type parameter from Instance
> -------------------------------------------------------
>                 Key: SOLDER-23
>                 URL: https://jira.jboss.org/browse/SOLDER-23
>             Project: Seam Solder
>          Issue Type: Feature Request
>            Reporter: Dan Allen
>            Priority: Minor
>             Fix For: 1.0.0.Beta2
> When discovering injection points, a type of Instance<T> is effectively the same as discovering a type T. You don't want to create a producer method for an Instance, for instance, hence why you want to figure out what T is. Thus, it's common to want to extract the type parameter from Instance. Having a utility would be convenient.
> Here's an example that collects the actual bean types (extracting from the Instance type parameter if necessary)
> Set<Type> types = new HashSet<Type>();
> for (InjectionPoint ip : event.getInjectionTarget().getInjectionPoints())
> {
>    types.add(Reflections.getActualType(ip.Type()));
> }
> Here's the utility:
> private static Type getActualType(Type t)
> {
>       if (t instanceof ParameterizedType && ((ParameterizedType) t).getRawType().equals(Instance.class))
>       {
>          return ((ParameterizedType) t).getActualTypeArguments()[0];
>       }
>       return t;
> }

This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the seam-issues mailing list