* Moved all l2 forwarding services based on OF to a separate OSGi
[affinity.git] / affinity / api / src / main / java / org / opendaylight / affinity / affinity / SetPathRedirect.java
diff --git a/affinity/api/src/main/java/org/opendaylight/affinity/affinity/SetPathRedirect.java b/affinity/api/src/main/java/org/opendaylight/affinity/affinity/SetPathRedirect.java
new file mode 100644 (file)
index 0000000..3e87d11
--- /dev/null
@@ -0,0 +1,72 @@
+package org.opendaylight.affinity.affinity;
+
+import java.net.InetAddress;
+import java.util.List;
+import java.util.ArrayList;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class SetPathRedirect extends AffinityAttribute {
+    private static final long serialVersionUID = 1L;
+    @XmlElement
+    private List<InetAddress> waypointList;
+
+    public SetPathRedirect() {
+        type = AffinityAttributeType.SET_PATH_REDIRECT;
+        waypointList = new ArrayList<InetAddress>();
+    }
+
+    public List<InetAddress> getWaypointList() {
+        return this.waypointList;
+    }
+
+    public void addWaypoint(InetAddress ipaddr) {
+        waypointList.add(ipaddr);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        for (InetAddress address: waypointList) {
+            result = prime * result + ((address == null) ? 0 : address.hashCode());
+        }
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        SetPathRedirect other = (SetPathRedirect) obj;
+        /* xxx check first element. */
+        InetAddress address = waypointList.get(0);
+        List<InetAddress> otherlist = other.getWaypointList();
+        return waypointList.equals(otherlist);
+    }
+
+    @Override
+    public String toString() {
+        String string = type + "[";
+        for (InetAddress address: waypointList) {
+            string = string + address.toString();
+        }
+        string = string +  "]";
+        return string;
+    }
+}
+
+
+