commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1138589 - in /commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model: BaseLabeledEdge.java BaseLabeledWeightedEdge.java
Date Wed, 22 Jun 2011 19:14:39 GMT
Author: simonetripodi
Date: Wed Jun 22 19:14:39 2011
New Revision: 1138589

URL: http://svn.apache.org/viewvc?rev=1138589&view=rev
Log:
label, head, tail, weight cannot be null

Modified:
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledEdge.java
    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/BaseLabeledEdge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledEdge.java?rev=1138589&r1=1138588&r2=1138589&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledEdge.java
(original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledEdge.java
Wed Jun 22 19:14:39 2011
@@ -36,6 +36,18 @@ public class BaseLabeledEdge
 
     public BaseLabeledEdge( String label, BaseLabeledVertex head, BaseLabeledVertex tail
)
     {
+        if ( label == null )
+        {
+            throw new IllegalArgumentException( "Argument 'label' must not be null" );
+        }
+        if ( head == null )
+        {
+            throw new IllegalArgumentException( "Argument 'head' must not be null" );
+        }
+        if ( tail == null )
+        {
+            throw new IllegalArgumentException( "Argument 'tail' must not be null" );
+        }
         this.label = label;
         this.head = head;
         this.tail = tail;
@@ -102,38 +114,17 @@ public class BaseLabeledEdge
 
         BaseLabeledEdge other = (BaseLabeledEdge) obj;
 
-        if ( head == null )
-        {
-            if ( other.getHead() != null )
-            {
-                return false;
-            }
-        }
-        else if ( !head.equals( other.getHead() ) )
+        if ( !head.equals( other.getHead() ) )
         {
             return false;
         }
 
-        if ( tail == null )
-        {
-            if ( other.getTail() != null )
-            {
-                return false;
-            }
-        }
-        else if ( !tail.equals( other.getTail() ) )
+        if ( !tail.equals( other.getTail() ) )
         {
             return false;
         }
 
-        if ( label == null )
-        {
-            if ( other.getLabel() != null )
-            {
-                return false;
-            }
-        }
-        else if ( !label.equals( other.label ) )
+        if ( !label.equals( other.label ) )
         {
             return false;
         }

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=1138589&r1=1138588&r2=1138589&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
Wed Jun 22 19:14:39 2011
@@ -36,6 +36,10 @@ public class BaseLabeledWeightedEdge
     public BaseLabeledWeightedEdge( String label, BaseLabeledVertex head, BaseLabeledVertex
tail, Double weight )
     {
         super( label, head, tail );
+        if ( weight == null )
+        {
+            throw new IllegalArgumentException( "Argument 'weight' must not be null" );
+        }
         this.weight = weight;
     }
 
@@ -89,14 +93,7 @@ public class BaseLabeledWeightedEdge
         }
 
         BaseLabeledWeightedEdge other = (BaseLabeledWeightedEdge) obj;
-        if ( weight == null )
-        {
-            if ( other.getWeight() != null )
-            {
-                return false;
-            }
-        }
-        else if ( !weight.equals( other.getWeight() ) )
+        if ( !weight.equals( other.getWeight() ) )
         {
             return false;
         }



Mime
View raw message