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/16 20:54:19 UTC
svn commit: r1136599 -
/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledVertex.java
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 );