commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r885514 - in /commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util: ListSetExecutor.java MapGetExecutor.java MapSetExecutor.java
Date Mon, 30 Nov 2009 17:43:43 GMT
Author: sebb
Date: Mon Nov 30 17:43:42 2009
New Revision: 885514

URL: http://svn.apache.org/viewvc?rev=885514&view=rev
Log:
Document why OK to suppress raw type cast warnings

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/ListSetExecutor.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapGetExecutor.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapSetExecutor.java

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/ListSetExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/ListSetExecutor.java?rev=885514&r1=885513&r2=885514&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/ListSetExecutor.java
(original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/ListSetExecutor.java
Mon Nov 30 17:43:42 2009
@@ -51,12 +51,12 @@
     }
     
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
     @Override
     public Object execute(final Object obj, Object value) {
         if (method == ARRAY_SET) {
             java.lang.reflect.Array.set(obj, property.intValue(), value);
         } else {
+            @SuppressWarnings("unchecked") // LSE should only be created for array or list
types
             final List<Object> list = (List<Object>) obj;
             list.set(property.intValue(), value);
         }
@@ -64,7 +64,6 @@
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
     @Override
     public Object tryExecute(final Object obj, Object key, Object value) {
         if (obj != null && method != null
@@ -73,6 +72,7 @@
             if (method == ARRAY_SET) {
                 Array.set(obj, ((Integer) key).intValue(), value);
             } else {
+                @SuppressWarnings("unchecked")  // LSE should only be created for array or
list types
                 final List<Object> list = (List<Object>) obj;
                 list.set(((Integer) key).intValue(), value);
             }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapGetExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapGetExecutor.java?rev=885514&r1=885513&r2=885514&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapGetExecutor.java
(original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapGetExecutor.java
Mon Nov 30 17:43:42 2009
@@ -52,20 +52,20 @@
      * @param obj the map.
      * @return map.get(property)
      */
-    @SuppressWarnings("unchecked")
     @Override
     public Object execute(final Object obj) {
+        @SuppressWarnings("unchecked") // ctor only allows Map instances - see discover()
method
         final Map<Object,?> map = (Map<Object, ?>) obj;
         return map.get(property);
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
     @Override
     public Object tryExecute(final Object obj, Object key) {
         if (obj != null &&  method != null
             && objectClass.equals(obj.getClass())
             && (key == null || property.getClass().equals(key.getClass()))) {
+            @SuppressWarnings("unchecked") // ctor only allows Map instances - see discover()
method
             final Map<Object,?> map = (Map<Object, ?>) obj;
             return map.get(key);
         }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapSetExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapSetExecutor.java?rev=885514&r1=885513&r2=885514&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapSetExecutor.java
(original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/util/MapSetExecutor.java
Mon Nov 30 17:43:42 2009
@@ -47,22 +47,22 @@
     }
     
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
     @Override
     public Object execute(final Object obj, Object value)
     throws IllegalAccessException, InvocationTargetException {
+        @SuppressWarnings("unchecked") // ctor only allows Map instances - see discover()
method
         final Map<Object,Object> map = ((Map<Object, Object>) obj);
         map.put(property, value);
         return value;
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
     @Override
     public Object tryExecute(final Object obj, Object key, Object value) {
         if (obj != null && method != null
             && objectClass.equals(obj.getClass())
             && (key == null || property.getClass().equals(key.getClass()))) {
+            @SuppressWarnings("unchecked") // ctor only allows Map instances - see discover()
method
             final Map<Object,Object> map = ((Map<Object, Object>) obj);
             map.put(key, value);
             return value;



Mime
View raw message