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:51:43 UTC
svn commit: r1234319 -
/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
Author: simonetripodi
Date: Sat Jan 21 12:51:43 2012
New Revision: 1234319
URL: http://svn.apache.org/viewvc?rev=1234319&view=rev
Log:
reuse assertions to verify label nullability
label cannot be null in the hasCode() method
Modified:
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java?rev=1234319&r1=1234318&r2=1234319&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java Sat Jan 21 12:51:43 2012
@@ -20,11 +20,12 @@ 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.WeightedEdge;
/**
- *
+ *
*/
public class BaseLabeledWeightedEdge
extends BaseLabeledEdge
@@ -36,11 +37,7 @@ public class BaseLabeledWeightedEdge
public BaseLabeledWeightedEdge( String label, Double weight )
{
super( label );
- if ( weight == null )
- {
- throw new IllegalArgumentException( "Argument 'weight' must not be null" );
- }
- this.weight = weight;
+ this.weight = checkNotNull( weight, "Argument 'weight' must not be null" );
}
/**
@@ -67,7 +64,7 @@ public class BaseLabeledWeightedEdge
{
final int prime = 31;
int result = super.hashCode();
- result = prime * result + ( ( weight == null ) ? 0 : weight.hashCode() );
+ result = prime * result + weight.hashCode();
return result;
}