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