commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1136599 - /commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledVertex.java
Date Thu, 16 Jun 2011 18:54:19 GMT
Author: simonetripodi
Date: Thu Jun 16 18:54:19 2011
New Revision: 1136599

URL: http://svn.apache.org/viewvc?rev=1136599&view=rev
Log:
implemented equals/hashCode methods

Modified:
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledVertex.java

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledVertex.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledVertex.java?rev=1136599&r1=1136598&r2=1136599&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledVertex.java
(original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledVertex.java
Thu Jun 16 18:54:19 2011
@@ -46,6 +46,55 @@ public class BaseLabeledVertex
      * {@inheritDoc}
      */
     @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( label == null ) ? 0 : label.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;
+        }
+
+        BaseLabeledVertex other = (BaseLabeledVertex) obj;
+        if ( label == null )
+        {
+            if ( other.getLabel() != null )
+            {
+                return false;
+            }
+        }
+        else if ( !label.equals( other.getLabel() ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public String toString()
     {
         return format( "Vertex(label=%s)", label );



Mime
View raw message