commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1234319 - /commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
Date Sat, 21 Jan 2012 12:51:43 GMT
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;
     }
 



Mime
View raw message