You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2009/07/16 21:12:59 UTC
svn commit: r794785 -
/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java
Author: gawor
Date: Thu Jul 16 19:12:59 2009
New Revision: 794785
URL: http://svn.apache.org/viewvc?rev=794785&view=rev
Log:
support WildcardType and TypeVariable
Modified:
geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java
Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java?rev=794785&r1=794784&r2=794785&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java Thu Jul 16 19:12:59 2009
@@ -142,8 +142,8 @@
return cl.getName();
}
- static GenericType[] parametersOf(Type type ) {
- if ( type instanceof Class ) {
+ static GenericType[] parametersOf(Type type) {
+ if (type instanceof Class) {
Class clazz = (Class) type;
if (clazz.isArray()) {
GenericType t = new GenericType(clazz.getComponentType());
@@ -156,7 +156,7 @@
return EMPTY;
}
}
- if ( type instanceof ParameterizedType ) {
+ if (type instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) type;
Type [] parameters = pt.getActualTypeArguments();
GenericType[] gts = new GenericType[parameters.length];
@@ -165,9 +165,27 @@
}
return gts;
}
- if ( type instanceof GenericArrayType ) {
+ if (type instanceof GenericArrayType) {
return new GenericType[] { new GenericType(((GenericArrayType) type).getGenericComponentType()) };
}
+ if (type instanceof WildcardType) {
+ WildcardType wildcard = (WildcardType) type;
+ Type[] types = null;
+ if (wildcard.getLowerBounds() == null || wildcard.getLowerBounds().length == 0) {
+ types = wildcard.getUpperBounds();
+ } else {
+ types = wildcard.getLowerBounds();
+ }
+ GenericType[] gts = new GenericType[types.length];
+ for (int i = 0; i < gts.length; i++) {
+ gts[i] = new GenericType(types[i]);
+ }
+ return gts;
+ }
+ if (type instanceof TypeVariable) {
+ TypeVariable typeVariable = (TypeVariable) type;
+ return new GenericType[] { new GenericType(typeVariable.getBounds()[0]) };
+ }
throw new IllegalStateException();
}