incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1136232 - in /incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util: IndexedAccess.java KeyedAccess.java
Date Wed, 15 Jun 2011 22:48:03 GMT
Author: mbenson
Date: Wed Jun 15 22:48:02 2011
New Revision: 1136232

URL: http://svn.apache.org/viewvc?rev=1136232&view=rev
Log:
default to object component type for unbound type variables

Modified:
    incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/IndexedAccess.java
    incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/KeyedAccess.java

Modified: incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/IndexedAccess.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/IndexedAccess.java?rev=1136232&r1=1136231&r2=1136232&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/IndexedAccess.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/IndexedAccess.java
Wed Jun 15 22:48:02 2011
@@ -21,6 +21,7 @@ import java.lang.reflect.Array;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang3.reflect.TypeUtils;
 
@@ -43,7 +44,8 @@ public class IndexedAccess extends Acces
             return TypeUtils.getArrayComponentType(containerType);
         }
         if (TypeUtils.isAssignable(containerType, Iterable.class)) {
-            return TypeUtils.getTypeArguments(containerType, Iterable.class).get(ITERABLE_TYPE);
+            Map<TypeVariable<?>, Type> typeArguments = TypeUtils.getTypeArguments(containerType,
Iterable.class);
+            return typeArguments.containsKey(ITERABLE_TYPE) ? typeArguments.get(ITERABLE_TYPE)
: Object.class;
         }
         return null;
     }

Modified: incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/KeyedAccess.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/KeyedAccess.java?rev=1136232&r1=1136231&r2=1136232&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/KeyedAccess.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util/KeyedAccess.java
Wed Jun 15 22:48:02 2011
@@ -42,7 +42,8 @@ public class KeyedAccess extends AccessS
      */
     public static Type getJavaElementType(Type containerType) {
         if (TypeUtils.isAssignable(containerType, Map.class)) {
-            return TypeUtils.getTypeArguments(containerType, Map.class).get(MAP_TYPEVARS[1]);
+            Map<TypeVariable<?>, Type> typeArguments = TypeUtils.getTypeArguments(containerType,
Map.class);
+            return typeArguments.containsKey(MAP_TYPEVARS[1]) ? typeArguments.get(MAP_TYPEVARS[1])
: Object.class;
         }
         return null;
     }
@@ -71,7 +72,7 @@ public class KeyedAccess extends AccessS
             Map<?, ?> map = (Map<?, ?>) instance;
             Map<TypeVariable<?>, Type> typeArguments = TypeUtils.getTypeArguments(containerType,
Map.class);
             Type keyType = typeArguments.get(MAP_TYPEVARS[0]);
-            if (key == null || TypeUtils.isInstance(key, keyType)) {
+            if (key == null || keyType == null || TypeUtils.isInstance(key, keyType)) {
                 return map.get(key);
             }
             if (key instanceof String) {



Mime
View raw message