Revert "Checkstyle enforcer"
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / action / SetNwDst.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.sal.action;
11
12 import java.net.InetAddress;
13
14 import javax.xml.bind.annotation.XmlAccessType;
15 import javax.xml.bind.annotation.XmlAccessorType;
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlRootElement;
18
19 /**
20  * Set network destination address action
21  */
22
23 @XmlRootElement
24 @XmlAccessorType(XmlAccessType.NONE)
25
26 public class SetNwDst extends Action {
27     InetAddress address;
28
29     /* Dummy constructor for JAXB */
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         if (!super.equals(obj))
57             return false;
58         if (getClass() != obj.getClass())
59             return false;
60         SetNwDst other = (SetNwDst) obj;
61         if (address == null) {
62             if (other.address != null)
63                 return false;
64         } else if (!address.equals(other.address))
65             return false;
66         return true;
67     }
68
69     @Override
70     public int hashCode() {
71         final int prime = 31;
72         int result = super.hashCode();
73         result = prime * result + ((address == null) ? 0 : address.hashCode());
74         return result;
75     }
76
77     @Override
78     public String toString() {
79         return type + "[address = " + address + "]";
80     }
81 }