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 2012/01/21 13:49:29 UTC
svn commit: r1234316 -
/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledVertex.java
Author: simonetripodi
Date: Sat Jan 21 12:49:29 2012
New Revision: 1234316
URL: http://svn.apache.org/viewvc?rev=1234316&view=rev
Log:
reuse assertions to verify label nullability
label cannot be null in the hasCode() method
label cannot be null in the toString() method
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=1234316&r1=1234315&r2=1234316&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 Sat Jan 21 12:49:29 2012
@@ -20,6 +20,7 @@ package org.apache.commons.graph.model;
*/
import static java.lang.String.format;
+import static org.apache.commons.graph.utils.Assertions.checkNotNull;
import org.apache.commons.graph.Labeled;
import org.apache.commons.graph.Vertex;
@@ -32,7 +33,7 @@ public class BaseLabeledVertex
public BaseLabeledVertex( String label )
{
- this.label = label;
+ this.label = checkNotNull( label, "Argument 'label' must not be null" );;
}
/**
@@ -51,7 +52,7 @@ public class BaseLabeledVertex
{
final int prime = 31;
int result = 1;
- result = prime * result + ( ( label == null ) ? 0 : label.hashCode() );
+ result = prime * result + label.hashCode();
return result;
}
@@ -77,14 +78,7 @@ public class BaseLabeledVertex
}
BaseLabeledVertex other = (BaseLabeledVertex) obj;
- if ( label == null )
- {
- if ( other.getLabel() != null )
- {
- return false;
- }
- }
- else if ( !label.equals( other.getLabel() ) )
+ if ( !label.equals( other.getLabel() ) )
{
return false;
}