Merge "Bug 1029: Remove dead code: samples/clustersession"
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / action / SetDlDst.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.util.Arrays;
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 import org.opendaylight.controller.sal.utils.HexEncode;
19
20 /**
21  * Set destination datalayer address action
22  */
23 @XmlRootElement
24 @XmlAccessorType(XmlAccessType.NONE)
25 public class SetDlDst extends Action {
26     private static final long serialVersionUID = 1L;
27     private byte[] address;
28
29     /* Dummy constructor for JAXB */
30     @SuppressWarnings("unused")
31     private SetDlDst() {
32     }
33
34     public SetDlDst(byte[] dlAddress) {
35         type = ActionType.SET_DL_DST;
36         this.address = dlAddress.clone();
37     }
38
39     /**
40      * Returns the datalayer address that this action will set
41      *
42      * @return byte[]
43      */
44     public byte[] getDlAddress() {
45         return address.clone();
46     }
47
48     @XmlElement(name = "address")
49     public String getDlAddressString() {
50         return HexEncode.bytesToHexString(address);
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         SetDlDst other = (SetDlDst) obj;
65         if (!Arrays.equals(address, other.address)) {
66             return false;
67         }
68         return true;
69     }
70
71     @Override
72     public int hashCode() {
73         final int prime = 31;
74         int result = super.hashCode();
75         result = prime * result + Arrays.hashCode(address);
76         return result;
77     }
78
79     @Override
80     public String toString() {
81         return type + "[address = " + HexEncode.bytesToHexString(address) + "]";
82     }
83 }