Update the Flow classes.
- Changed all Flow classes to use FlowId object on its constructor for their ID.
- Implement equals() and hashCode() for all Flow classes based on FlowId.
- Changed SingleDstTreeFlow class to accept the list of Action objects on its constructor.
- Updated the Tree class's constructor to accept the list of links.
- This task is a part of ONOS-1841, ONOS-1694, ONOS-1741.
Change-Id: I930007ce7f92b5bbde4efef9eb9ab893c356abf1
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/Path.java b/src/main/java/net/onrc/onos/api/flowmanager/Path.java
index df61e51..2f733a4 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/Path.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/Path.java
@@ -1,5 +1,7 @@
package net.onrc.onos.api.flowmanager;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -18,6 +20,35 @@
}
/**
+ * Constructor to create the object from the list of FlowLinks.
+ *
+ * @param links the list of FlowLinks
+ * @throws IllegalArgumentException if the links does not form a single
+ * connected directed path topology
+ */
+ public Path(List<FlowLink> links) {
+ super();
+ checkNotNull(links);
+ for (FlowLink link : links) {
+ if (!addLink(link)) {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ /**
+ * Adds FlowLink to the Path object.
+ *
+ * @param link the FlowLink object to be added
+ * @return true if succeeded, false otherwise
+ */
+ public boolean addLink(FlowLink link) {
+ // TODO check connectivity
+ checkNotNull(link);
+ return add(link);
+ }
+
+ /**
* Gets a list of switch DPIDs of the path.
*
* @return a list of Dpid objects
@@ -29,7 +60,7 @@
List<Dpid> dpids = new ArrayList<Dpid>(size() + 1);
dpids.add(getSrcDpid());
- for (FlowLink link: this) {
+ for (FlowLink link : this) {
dpids.add(link.getDstDpid());
}
return dpids;