Add reverse() method in Edge and Path classes 53/5453/2
authorChi-Vien Ly <chivly@cisco.com>
Mon, 24 Feb 2014 20:23:31 +0000 (12:23 -0800)
committerChi-Vien Ly <chivly@cisco.com>
Tue, 25 Feb 2014 16:49:37 +0000 (08:49 -0800)
Change-Id: I27ada22079999facf6e9f00e05b60aa480e4f2b9
Signed-off-by: Chi-Vien Ly <chivly@cisco.com>
opendaylight/commons/opendaylight/pom.xml
opendaylight/md-sal/pom.xml
opendaylight/sal/api/pom.xml
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Edge.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Path.java

index 43b69e4d87d4eb3838a2ff2945b3195d1f5aefab..6e178ca2c92b53221041eb223b510e2e834697c5 100644 (file)
@@ -84,7 +84,7 @@
     <containermanager.it.version>0.5.2-SNAPSHOT</containermanager.it.version>
     <switchmanager.api.version>0.7.1-SNAPSHOT</switchmanager.api.version>
     <connectionmanager.version>0.1.2-SNAPSHOT</connectionmanager.version>
-    <sal.version>0.7.1-SNAPSHOT</sal.version>
+    <sal.version>0.8.1-SNAPSHOT</sal.version>
     <sal.networkconfiguration.version>0.0.3-SNAPSHOT</sal.networkconfiguration.version>
     <sal.connection.version>0.1.2-SNAPSHOT</sal.connection.version>
     <networkconfig.bridgedomain.northbound.version>0.0.3-SNAPSHOT</networkconfig.bridgedomain.northbound.version>
index f900c0b18c6558e0808c7fca3452bf3608aaeddf..e4190fbd7f2d838e655cdf0279c58ef8dd2b891a 100644 (file)
         <sonar.branch>${user.name}-private-view</sonar.branch>
         <sonar.language>java</sonar.language>
         <exam.version>3.0.0</exam.version>
-        <sal.version>0.7.1-SNAPSHOT</sal.version>
+        <sal.version>0.8.1-SNAPSHOT</sal.version>
     </properties>
 
     <dependencyManagement>
index 16868f55170deab4120ac7064fa849cb6da87c9d..326755309d7f01a01749055753a302d1248acd47 100644 (file)
@@ -15,7 +15,7 @@
   </scm>
 
   <artifactId>sal</artifactId>
-  <version>0.7.1-SNAPSHOT</version>
+  <version>0.8.1-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <build>
index 7f398db6f12e8def650afa50be7a0ee888460906..0dffee9c474de57797117a218f4aa019e6a33e85 100644 (file)
@@ -85,6 +85,19 @@ public class Edge implements Serializable {
         }
     }
 
+    /**
+     * Create the reversed edge
+     * @return The reversed edge.
+     */
+    public Edge reverse() {
+        Edge re;
+        try {
+            re = new Edge(this.headNodeConnector, this.tailNodeConnector);
+        } catch (ConstructionException e) {
+            re = null;
+        }
+        return re;
+    }
     /**
      * getter of edge
      *
index 31b3ec6a5a164c96cc1c8ea04aa06e35b8197eab..ba2394131d84cb962696d2e955d4bbeb0866f277 100644 (file)
@@ -17,6 +17,8 @@
 package org.opendaylight.controller.sal.core;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -81,6 +83,39 @@ public class Path implements Serializable {
         this.edges = edges;
     }
 
+    /**
+     * Create the reversed path
+     * @return The reversed path
+     */
+    public Path reverse() {
+        int j = edges.size(); // size always > 0
+        Edge[]  aEdges = new Edge[j];
+        for (Edge e : edges) {
+            j--;
+            aEdges[j] = e.reverse();
+        }
+        Path rp;
+        try {
+         rp = new Path(Arrays.asList(aEdges));
+        } catch (ConstructionException ce) {
+            rp = null;
+        }
+        return rp;
+    }
+
+    /**
+     * Return the list of nodes of this path, the first node is the start node
+     * @return the list of nodes
+     */
+    public List<Node> getNodes() {
+        List<Node> nl = new ArrayList<Node>();
+        nl.add(this.getStartNode());
+        for (Edge e : edges) {
+            nl.add(e.getHeadNodeConnector().getNode());
+        }
+        return nl;
+    }
+
     /**
      * Copy Construct for a path
      *