[
https://jira.jboss.org/browse/WELDX-188?page=com.atlassian.jira.plugin.sy...
]
Dan Allen commented on WELDX-188:
---------------------------------
Ah, parameters are strictly typed. So while the exact still shouldn't be exact,
parameter types do have to be equal.
I'll provide three test cases that should pass.
Type generalType1 = new TypeLiteral<Instance<? extends Number>>()
{}.getType();
Type specificType1 = new TypeLiteral<Instance<Integer>>() {}.getType();
Assert.assertTrue(TypeHelper.get(generalType1).isAssignableFrom(specificType1));
Type generalType2 = new TypeLiteral<Provider<? extends Number>>()
{}.getType();
Type specificType2 = new TypeLiteral<Instance<Integer>>() {}.getType();
Assert.assertTrue(TypeHelper.get(generalType2).isAssignableFrom(specificType2));
Type generalType3 = new TypeLiteral<Number>() {}.getType();
Type specificType3 = new TypeLiteral<Integer>() {}.getType();
Assert.assertTrue(TypeHelper.get(generalType3).isAssignableFrom(specificType3));
Being able to shove off dealing with the specifics of the various types is quite helpful.
Provide utility to check if Type is assignable to another Type
--------------------------------------------------------------
Key: WELDX-188
URL:
https://jira.jboss.org/browse/WELDX-188
Project: Weld Extensions
Issue Type: Feature Request
Reporter: Dan Allen
Priority: Minor
Fix For: 1.0.0.Beta2
Often times when writing an extension, you need to know if one Type is assignable from
another Type. This is a more sophisticated version of Class#isAssignableFrom(Class) which
takes into account paramaterized types.
given
parameterized type Bean<N extends Number>
then
type Bean<Number> is assignable from type Bean<Integer>
One area where this is useful is when checking if a bean type is more specific than
another bean type. It's not sufficient to assume the bean type is a simple class.
Something similar to what is provided by:
http://google-gson.googlecode.com/svn-history/r442/trunk/gson/src/main/ja...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira