You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2010/06/26 21:40:40 UTC

svn commit: r958273 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/concurrent/test/ base/src/org/ofbiz/base/lang/test/ base/src/org/ofbiz/base/util/ base/src/org/ofbiz/base/util/cache/ base/src/org/ofbiz/base/util/string/test/ base/src/org/ofbiz/...

Author: doogie
Date: Sat Jun 26 19:40:39 2010
New Revision: 958273

URL: http://svn.apache.org/viewvc?rev=958273&view=rev
Log:
Fix several generics warnings that have crept in.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/test/DependencyPoolTests.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/test/ComparableRangeTests.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilObjectTests.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/test/DependencyPoolTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/test/DependencyPoolTests.java?rev=958273&r1=958272&r2=958273&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/test/DependencyPoolTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/test/DependencyPoolTests.java Sat Jun 26 19:40:39 2010
@@ -23,7 +23,7 @@ public class DependencyPoolTests extends
     public void testDependencyPool() throws Exception {
         // always use more threads than cpus, so that the single-cpu case can be tested
         ScheduledExecutorService executor = ExecutionPool.getNewOptimalExecutor(getName());
-        DependencyPool pool = new DependencyPool(executor);
+        DependencyPool<Integer, TestItem, String> pool = new DependencyPool<Integer, TestItem, String>(executor);
         int itemSize = 100, depMax = 5, subMax = 3;
         List<TestItem> items = new ArrayList<TestItem>(itemSize);
         List<TestItem> previousItems = new ArrayList<TestItem>(itemSize);
@@ -70,13 +70,13 @@ OUTER:
     }
 
     private static class TestItem implements DependencyPool.Item<TestItem, Integer, String> {
-        private final DependencyPool pool;
+        private final DependencyPool<Integer, TestItem, String> pool;
         private final Integer key;
         private final String result;
         private final Collection<Integer> dependencies;
         private final Collection<TestItem> subItems;
 
-        protected TestItem(DependencyPool pool, Integer key, String result, Collection<Integer> dependencies, Collection<TestItem> subItems) {
+        protected TestItem(DependencyPool<Integer, TestItem, String> pool, Integer key, String result, Collection<Integer> dependencies, Collection<TestItem> subItems) {
             this.pool = pool;
             this.key = key;
             this.result = result;

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/test/ComparableRangeTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/test/ComparableRangeTests.java?rev=958273&r1=958272&r2=958273&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/test/ComparableRangeTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/test/ComparableRangeTests.java Sat Jun 26 19:40:39 2010
@@ -21,6 +21,7 @@ package org.ofbiz.base.lang.test;
 import org.ofbiz.base.test.GenericTestCaseBase;
 import org.ofbiz.base.lang.ComparableRange;
 import org.ofbiz.base.lang.SourceMonitored;
+import org.ofbiz.base.util.UtilGenerics;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
@@ -79,7 +80,7 @@ public class ComparableRangeTests extend
         assertFalse(label + ":a-d equals null", all.equals(null));
         ClassCastException caught = null;
         try {
-            ((Comparable) first).compareTo(ComparableRangeTests.class);
+            UtilGenerics.<Comparable<Object>>cast(first).compareTo(ComparableRangeTests.class);
         } catch (ClassCastException e) {
             caught = e;
         } finally {

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java?rev=958273&r1=958272&r2=958273&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilIO.java Sat Jun 26 19:40:39 2010
@@ -361,11 +361,11 @@ public final class UtilIO {
         out.close();
     }
 
-    private static boolean encodeObject(Writer writer, Object value, boolean allowJsonResolve) throws Exception {
-        Converter converter = Converters.getConverter(value.getClass(), String.class);
+    private static <T> boolean encodeObject(Writer writer, T value, boolean allowJsonResolve) throws Exception {
+        Converter<T, String> converter = UtilGenerics.cast(Converters.getConverter(value.getClass(), String.class));
         if (converter != null) {
             Class clz = converter.getSourceClass();
-            String str = (String) converter.convert(value);
+            String str = converter.convert(value);
             if (clz != null) {
                 writer.write(clz.getName());
             } else {

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java?rev=958273&r1=958272&r2=958273&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java Sat Jun 26 19:40:39 2010
@@ -44,6 +44,7 @@ import jdbm.htree.HTree;
 import org.ofbiz.base.concurrent.ExecutionPool;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.ObjectType;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilObject;
 import org.ofbiz.base.util.UtilValidate;
 
@@ -459,7 +460,7 @@ public class UtilCache<K, V> implements 
                 } else {
                     hitCount.incrementAndGet();
                 }
-                memoryTable.put(nulledKey, createCacheLine((K) key, value, expireTimeNanos));
+                memoryTable.put(nulledKey, createCacheLine(UtilGenerics.<K>cast(key), value, expireTimeNanos));
                 return value;
             } else {
                 missCountNotFound.incrementAndGet();
@@ -595,7 +596,7 @@ public class UtilCache<K, V> implements 
                 Debug.logError(e, module);
             }
         }
-        noteRemoval((K) key, existingCacheLine.getValue());
+        noteRemoval(UtilGenerics.<K>cast(key), existingCacheLine.getValue());
     }
 
     /** Removes all elements from this cache */
@@ -869,7 +870,7 @@ public class UtilCache<K, V> implements 
                 keys = memoryTable.keySet();
             }
         }
-        return Collections.unmodifiableSet((Set<? extends K>) keys);
+        return Collections.unmodifiableSet(UtilGenerics.<Set<? extends K>>cast(keys));
     }
 
     public Collection<? extends CacheLine<V>> getCacheLineValues() {

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java?rev=958273&r1=958272&r2=958273&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java Sat Jun 26 19:40:39 2010
@@ -237,12 +237,12 @@ public class FlexibleStringExpanderTests
     }
 
     @SuppressWarnings("unchecked")
-    public static class SpecialNumberToString extends AbstractConverter {
+    public static class SpecialNumberToString extends AbstractConverter<SpecialNumber, String> {
         public SpecialNumberToString() {
             super(SpecialNumber.class, String.class);
         }
 
-        public Object convert(Object obj) throws ConversionException {
+        public String convert(SpecialNumber obj) throws ConversionException {
             throw new NullPointerException();
         }
     }

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilObjectTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilObjectTests.java?rev=958273&r1=958272&r2=958273&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilObjectTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/UtilObjectTests.java Sat Jun 26 19:40:39 2010
@@ -226,7 +226,7 @@ public class UtilObjectTests extends Gen
             assertNull("parse empty array", UtilObject.getObject(new byte[0]));
 
             // simulate a ClassNotFoundException
-            Object groovySerializable = GroovyUtil.eval("class foo implements java.io.Serializable { }; return new foo()", new HashMap());
+            Object groovySerializable = GroovyUtil.eval("class foo implements java.io.Serializable { }; return new foo()", new HashMap<String, Object>());
             byte[] groovySerializableBytes = UtilObject.getBytes(groovySerializable);
             assertNotNull("groovySerializableBytes", groovySerializableBytes);
             assertNull("groovyDeserializable", UtilObject.getObject(groovySerializableBytes));

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=958273&r1=958272&r2=958273&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Sat Jun 26 19:40:39 2010
@@ -2820,7 +2820,7 @@ public class MacroFormRenderer implement
             ajaxUrl += "," + ajaxParams;
         }
         Locale locale = UtilMisc.ensureLocale(context.get("locale"));
-        MapStack<String> localContext = MapStack.create( (Map<String,Object>)context);
+        MapStack<String> localContext = MapStack.create(UtilGenerics.<Map<String,Object>>cast(context));
         return FlexibleStringExpander.expandString(ajaxUrl, localContext, locale);
     }
     /** Extracts parameters from a target URL string, prepares them for an Ajax