Merge "Add reverse() method in Edge and Path classes"
authorAlessandro Boch <aboch@cisco.com>
Tue, 25 Feb 2014 23:51:11 +0000 (23:51 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 25 Feb 2014 23:51:11 +0000 (23:51 +0000)
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 43e254c..acda400 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 562db98..6cc06ba 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 16868f5..3267553 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 7f398db..0dffee9 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 31b3ec6..ba23941 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
      *

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.