Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / action / SetNwSrc.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 source address action
20  */
21
22 @XmlRootElement
23 @XmlAccessorType(XmlAccessType.NONE)
24 @Deprecated
25 public class SetNwSrc extends Action {
26     private static final long serialVersionUID = 1L;
27     InetAddress address;
28
29     /* Dummy constructor for JAXB */
30     @SuppressWarnings("unused")
31     private SetNwSrc() {
32     }
33
34     public SetNwSrc(InetAddress address) {
35         type = ActionType.SET_NW_SRC;
36         this.address = address;
37     }
38
39     /**
40      * Returns the network address this action will set
41      *
42      * @return InetAddress
43      */
44     public InetAddress getAddress() {
45         return address;
46     }
47
48     @XmlElement(name = "address")
49     public String getAddressAsString() {
50         return address.getHostAddress();
51     }
52
53     @Override
54     public boolean equals(Object obj) {
55         if (this == obj) {
56             return true;
57         }
58         if (!super.equals(obj)) {
59             return false;
60         }
61         if (getClass() != obj.getClass()) {
62             return false;
63         }
64         SetNwSrc other = (SetNwSrc) obj;
65         if (address == null) {
66             if (other.address != null) {
67                 return false;
68             }
69         } else if (!address.equals(other.address)) {
70             return false;
71         }
72         return true;
73     }
74
75     @Override
76     public int hashCode() {
77         final int prime = 31;
78         int result = super.hashCode();
79         result = prime * result + ((address == null) ? 0 : address.hashCode());
80         return result;
81     }
82
83     @Override
84     public String toString() {
85         return type + "[address = " + address + "]";
86     }
87 }