You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/06/12 01:56:34 UTC

svn commit: r1134835 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/decorator/DDirectedGraph.java

Author: simonetripodi
Date: Sat Jun 11 23:56:33 2011
New Revision: 1134835

URL: http://svn.apache.org/viewvc?rev=1134835&view=rev
Log:
fixed DECORATED_GRAPHS cache type
suppressed warnings where possible

Modified:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/decorator/DDirectedGraph.java

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/decorator/DDirectedGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/decorator/DDirectedGraph.java?rev=1134835&r1=1134834&r2=1134835&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/decorator/DDirectedGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/decorator/DDirectedGraph.java Sat Jun 11 23:56:33 2011
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.graph.DirectedGraph;
+import org.apache.commons.graph.Edge;
 import org.apache.commons.graph.GraphException;
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
@@ -43,7 +44,8 @@ public class DDirectedGraph<V extends Ve
     implements DirectedGraph<V, WE>, WeightedGraph<V, WE>
 {
 
-    private static final Map DECORATED_GRAPHS = new HashMap();// DGRAPH X DDGRAPH
+    private static final Map<DirectedGraph<? extends Vertex, ? extends Edge>, DDirectedGraph<? extends Vertex, ? extends Edge>>
+    DECORATED_GRAPHS = new HashMap<DirectedGraph<? extends Vertex, ? extends Edge>, DDirectedGraph<? extends Vertex, ? extends Edge>>();// DGRAPH X DDGRAPH
 
     /**
      * Description of the Method
@@ -57,7 +59,9 @@ public class DDirectedGraph<V extends Ve
 
         if ( DECORATED_GRAPHS.containsKey( graph ) )
         {
-            return (DDirectedGraph<V, WE>) DECORATED_GRAPHS.get( graph );
+            @SuppressWarnings( "unchecked" ) // driven by graph parameter type
+            DDirectedGraph<V, WE> decorated = (DDirectedGraph<V, WE>) DECORATED_GRAPHS.get( graph );
+            return decorated;
         }
 
         DDirectedGraph<V, WE> decorated = new DDirectedGraph<V, WE>( graph );
@@ -82,7 +86,9 @@ public class DDirectedGraph<V extends Ve
 
         if ( impl instanceof WeightedGraph )
         {
-            weighted = (WeightedGraph<V, WE>) impl;
+            @SuppressWarnings( "unchecked" ) // impl is DirectedGraph<V, WE>
+            WeightedGraph<V, WE> tmp = (WeightedGraph<V, WE>) impl;
+            weighted = tmp;
         }
         else
         {