33d9b9361d1262c919c3576742c9b40fad1b19f2
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / action / SetNextHop.java
1 package org.opendaylight.controller.sal.action;
2
3 import java.net.InetAddress;
4
5 import javax.xml.bind.annotation.XmlAccessType;
6 import javax.xml.bind.annotation.XmlAccessorType;
7 import javax.xml.bind.annotation.XmlElement;
8 import javax.xml.bind.annotation.XmlRootElement;
9
10 @XmlRootElement
11 @XmlAccessorType(XmlAccessType.NONE)
12 public class SetNextHop extends Action {
13     @XmlElement
14     private InetAddress address;
15
16     /* Dummy constructor for JAXB */
17     @SuppressWarnings("unused")
18     private SetNextHop() {
19     }
20
21     public SetNextHop(InetAddress address) {
22         type = ActionType.SET_NEXT_HOP;
23         this.address = address;
24     }
25
26     public InetAddress getAddress() {
27         return address;
28     }
29
30     @Override
31     public int hashCode() {
32         final int prime = 31;
33         int result = super.hashCode();
34         result = prime * result + ((address == null) ? 0 : address.hashCode());
35         return result;
36     }
37
38     @Override
39     public boolean equals(Object obj) {
40         if (this == obj) {
41             return true;
42         }
43         if (!super.equals(obj)) {
44             return false;
45         }
46         if (getClass() != obj.getClass()) {
47             return false;
48         }
49         SetNextHop other = (SetNextHop) obj;
50         if (address == null) {
51             if (other.address != null) {
52                 return false;
53             }
54         } else if (!address.equals(other.address)) {
55             return false;
56         }
57         return true;
58     }
59
60     @Override
61     public String toString() {
62         return type + "[" + address.toString() + "]";
63     }
64 }