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