db19cd6520879e7da302b43a1697172691f4248a
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / action / SetNwDst.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.sal.action;
10
11 import java.net.InetAddress;
12
13 import javax.xml.bind.annotation.XmlAccessType;
14 import javax.xml.bind.annotation.XmlAccessorType;
15 import javax.xml.bind.annotation.XmlElement;
16 import javax.xml.bind.annotation.XmlRootElement;
17
18 /**
19  * Set network destination address action
20  */
21
22 @XmlRootElement
23 @XmlAccessorType(XmlAccessType.NONE)
24 public class SetNwDst extends Action {
25     private static final long serialVersionUID = 1L;
26     InetAddress address;
27
28     /* Dummy constructor for JAXB */
29     @SuppressWarnings("unused")
30     private SetNwDst() {
31     }
32
33     public SetNwDst(InetAddress address) {
34         type = ActionType.SET_NW_DST;
35         this.address = address;
36     }
37
38     /**
39      * Returns the network address this action will set
40      *
41      * @return InetAddress
42      */
43     public InetAddress getAddress() {
44         return address;
45     }
46
47     @XmlElement(name = "address")
48     public String getAddressAsString() {
49         return address.getHostAddress();
50     }
51
52     @Override
53     public boolean equals(Object obj) {
54         if (this == obj) {
55             return true;
56         }
57         if (!super.equals(obj)) {
58             return false;
59         }
60         if (getClass() != obj.getClass()) {
61             return false;
62         }
63         SetNwDst other = (SetNwDst) obj;
64         if (address == null) {
65             if (other.address != null) {
66                 return false;
67             }
68         } else if (!address.equals(other.address)) {
69             return false;
70         }
71         return true;
72     }
73
74     @Override
75     public int hashCode() {
76         final int prime = 31;
77         int result = super.hashCode();
78         result = prime * result + ((address == null) ? 0 : address.hashCode());
79         return result;
80     }
81
82     @Override
83     public String toString() {
84         return type + "[address = " + address + "]";
85     }
86 }