Author: simonetripodi
Date: Sat Jun 18 14:01:33 2011
New Revision: 1137188

URL: http://svn.apache.org/viewvc?rev=1137188&view=rev
Log:
added equals/toString for test purposes

Modified:
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java?rev=1137188&r1=1137187&r2=1137188&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java
 Sat Jun 18 14:01:33 2011
@@ -104,4 +104,44 @@ public abstract class BaseGraph<V extend
         return allEdges;
     }
 
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+
+        if ( obj == null )
+        {
+            return false;
+        }
+
+        if ( getClass() != obj.getClass() )
+        {
+            return false;
+        }
+
+        @SuppressWarnings( "unchecked" ) // test against any Graph typed 
instance
+        BaseGraph<Vertex, Edge<Vertex>> other = (BaseGraph<Vertex, 
Edge<Vertex>>) obj;
+        if ( !adjacencyList.equals( other.getAdjacencyList() ) )
+        {
+            return false;
+        }
+        if ( !allEdges.equals( other.getAllEdges() ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString()
+    {
+        return String.valueOf( getAdjacencyList() );
+    }
+
 }


Reply via email to