Mark AD-SAL interfaces as deprecated
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / match / extensible / DlDst.java
1 package org.opendaylight.controller.sal.match.extensible;
2
3 import java.util.Arrays;
4
5 import javax.xml.bind.annotation.XmlAccessType;
6 import javax.xml.bind.annotation.XmlAccessorType;
7 import javax.xml.bind.annotation.XmlElement;
8 import javax.xml.bind.annotation.XmlRootElement;
9
10 import org.opendaylight.controller.sal.utils.HexEncode;
11 import org.opendaylight.controller.sal.utils.NetUtils;
12
13 @XmlRootElement
14 @XmlAccessorType(XmlAccessType.NONE)
15 @Deprecated
16 public class DlDst extends MatchField<byte[]> {
17     private static final long serialVersionUID = 1L;
18     public static final String TYPE = "DL_DST";
19     private byte[] address;
20
21     /**
22      * Creates a Match field for the destination data layer address
23      *
24      * @param address
25      *            the data layer address. The constructor makes a copy of it
26      */
27     public DlDst(byte[] address) {
28         super(TYPE);
29         if (address != null) {
30             this.address = Arrays.copyOf(address, address.length);
31         }
32     }
33
34     // To satisfy JAXB
35     public DlDst() {
36         super(TYPE);
37     }
38
39     @Override
40     public byte[] getValue() {
41         return Arrays.copyOf(address, address.length);
42     }
43
44     @Override
45     @XmlElement(name = "value")
46     protected String getValueString() {
47         return HexEncode.bytesToHexStringFormat(address);
48     }
49
50     @Override
51     public byte[] getMask() {
52         return null;
53     }
54
55     @Override
56     protected String getMaskString() {
57         return null;
58     }
59
60     @Override
61     public boolean isValid() {
62         return address != null && address.length == NetUtils.MACAddrLengthInBytes;
63     }
64
65     @Override
66     public boolean hasReverse() {
67         return true;
68     }
69
70     @Override
71     public DlSrc getReverse() {
72         return new DlSrc(address);
73     }
74
75     @Override
76     public DlDst clone() {
77         return new DlDst(address);
78     }
79
80     @Override
81     public boolean isV6() {
82         return true;
83     }
84
85     @Override
86     public int hashCode() {
87         final int prime = 31;
88         int result = 1;
89         result = prime * result + Arrays.hashCode(address);
90         return result;
91     }
92
93     @Override
94     public boolean equals(Object obj) {
95         if (this == obj) {
96             return true;
97         }
98         if (obj == null) {
99             return false;
100         }
101         if (!(obj instanceof DlDst)) {
102             return false;
103         }
104         DlDst other = (DlDst) obj;
105         return Arrays.equals(address, other.address);
106     }
107 }