Author: simonetripodi
Date: Thu Jun 16 21:15:54 2011
New Revision: 1136684

URL: http://svn.apache.org/viewvc?rev=1136684&view=rev
Log:
added hashCode (useless?!?) and equals (needed at least in tests) methods 
implementation

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

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java?rev=1136684&r1=1136683&r2=1136684&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java
 Thu Jun 16 21:15:54 2011
@@ -129,6 +129,72 @@ public final class InMemoryPath<V extend
      * {@inheritDoc}
      */
     @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( edges == null ) ? 0 : edges.hashCode() );
+        result = prime * result + ( ( source == null ) ? 0 : source.hashCode() 
);
+        result = prime * result + ( ( target == null ) ? 0 : target.hashCode() 
);
+        result = prime * result + ( ( vertices == null ) ? 0 : 
vertices.hashCode() );
+        result = prime * result + ( ( weigth == null ) ? 0 : weigth.hashCode() 
);
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+
+        if ( obj == null )
+        {
+            return false;
+        }
+
+        if ( getClass() != obj.getClass() )
+        {
+            return false;
+        }
+
+        InMemoryPath other = (InMemoryPath) obj;
+        if ( !source.equals( other.getSource() ) )
+        {
+            return false;
+        }
+
+        if ( !target.equals( other.target ) )
+        {
+            return false;
+        }
+
+        if ( !vertices.equals( other.vertices ) )
+        {
+            return false;
+        }
+
+        if ( !edges.equals( other.getEdges() ) )
+        {
+            return false;
+        }
+
+        if ( !weigth.equals( other.weigth ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public String toString()
     {
         return format( "InMemoryPath [weigth=%s, vertices=%s, edges=%s]", 
weigth, vertices, edges );


Reply via email to