bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r996016 - in /incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/util: IndexedAccess.java KeyedAccess.java
Date Fri, 10 Sep 2010 23:43:29 GMT
Author: mbenson
Date: Fri Sep 10 23:43:29 2010
New Revision: 996016

URL: http://svn.apache.org/viewvc?rev=996016&view=rev
Log:
make static methods return null if not applicable so we can use them to detect stuff

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=996016&r1=996015&r2=996016&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
Fri Sep 10 23:43:29 2010
@@ -35,7 +35,8 @@ public class IndexedAccess extends Acces
      * Get the Java element type of a particular container type.
      * 
      * @param containerType
-     * @return Type
+     * @return Type or <code>null</code> if <code>containerType</code>
is not
+     *         some type of {@link Iterable} or array
      */
     public static Type getJavaElementType(Type containerType) {
         if (TypeUtils.isArrayType(containerType)) {
@@ -44,7 +45,7 @@ public class IndexedAccess extends Acces
         if (TypeUtils.isAssignable(containerType, Iterable.class)) {
             return TypeUtils.getTypeArguments(containerType, Iterable.class).get(ITERABLE_TYPE);
         }
-        return Object.class;
+        return null;
     }
 
     private Type containerType;

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=996016&r1=996015&r2=996016&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
Fri Sep 10 23:43:29 2010
@@ -37,13 +37,14 @@ public class KeyedAccess extends AccessS
      * Get the Java element type of a particular container type.
      * 
      * @param containerType
-     * @return Type
+     * @return Type or <code>null</code> if <code>containerType</code>
is not
+     *         some kind of {@link Map}
      */
     public static Type getJavaElementType(Type containerType) {
         if (TypeUtils.isAssignable(containerType, Map.class)) {
             return TypeUtils.getTypeArguments(containerType, Map.class).get(MAP_TYPEVARS[1]);
         }
-        return Object.class;
+        return null;
     }
 
     private Type containerType;
@@ -104,7 +105,8 @@ public class KeyedAccess extends AccessS
      */
     @Override
     public Type getJavaType() {
-        return getJavaElementType(containerType);
+        Type result = getJavaElementType(containerType);
+        return result == null ? Object.class : result;
     }
 
     /**



Mime
View raw message