commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1134835 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/decorator/DDirectedGraph.java
Date Sat, 11 Jun 2011 23:56:34 GMT
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
         {



Mime
View raw message