* 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
1 package org.opendaylight.affinity.affinity;
2
3 import java.net.InetAddress;
4 import java.util.List;
5 import java.util.ArrayList;
6
7 import javax.xml.bind.annotation.XmlAccessType;
8 import javax.xml.bind.annotation.XmlAccessorType;
9 import javax.xml.bind.annotation.XmlElement;
10 import javax.xml.bind.annotation.XmlRootElement;
11
12 @XmlRootElement
13 @XmlAccessorType(XmlAccessType.NONE)
14 public class SetPathRedirect extends AffinityAttribute {
15     private static final long serialVersionUID = 1L;
16     @XmlElement
17     private List<InetAddress> waypointList;
18
19     public SetPathRedirect() {
20         type = AffinityAttributeType.SET_PATH_REDIRECT;
21         waypointList = new ArrayList<InetAddress>();
22     }
23
24     public List<InetAddress> getWaypointList() {
25         return this.waypointList;
26     }
27
28     public void addWaypoint(InetAddress ipaddr) {
29         waypointList.add(ipaddr);
30     }
31
32     @Override
33     public int hashCode() {
34         final int prime = 31;
35         int result = super.hashCode();
36         for (InetAddress address: waypointList) {
37             result = prime * result + ((address == null) ? 0 : address.hashCode());
38         }
39         return result;
40     }
41
42     @Override
43     public boolean equals(Object obj) {
44         if (this == obj) {
45             return true;
46         }
47         if (!super.equals(obj)) {
48             return false;
49         }
50         if (getClass() != obj.getClass()) {
51             return false;
52         }
53         SetPathRedirect other = (SetPathRedirect) obj;
54         /* xxx check first element. */
55         InetAddress address = waypointList.get(0);
56         List<InetAddress> otherlist = other.getWaypointList();
57         return waypointList.equals(otherlist);
58     }
59
60     @Override
61     public String toString() {
62         String string = type + "[";
63         for (InetAddress address: waypointList) {
64             string = string + address.toString();
65         }
66         string = string +  "]";
67         return string;
68     }
69 }
70
71
72