BUG 2302 : odl-clustering-test-app should not be part of the odl-restconf-all feature set
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / match / extensible / DlVlanPriority.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.NetUtils;
9
10 @XmlRootElement
11 @XmlAccessorType(XmlAccessType.NONE)
12 public class DlVlanPriority extends MatchField<Byte> {
13     private static final long serialVersionUID = 1L;
14     public static final String TYPE = "DL_VLAN_PR";
15     private static final byte MAX = 7;
16     private byte vlanPriority;
17
18     /**
19      * Creates a Match field for the data layer type
20      *
21      * @param address
22      *            the data layer type
23      */
24     public DlVlanPriority(byte vlanPriority) {
25         super(TYPE);
26         this.vlanPriority = vlanPriority;
27     }
28
29     // To satisfy JAXB
30     private DlVlanPriority() {
31         super(TYPE);
32     }
33
34     @Override
35     public Byte getValue() {
36         return vlanPriority;
37     }
38
39     @Override
40     @XmlElement(name = "mask")
41     protected String getValueString() {
42         return String.format("0X%s", Integer.toHexString(NetUtils.getUnsignedByte(vlanPriority)));
43     }
44
45     @Override
46     public Byte getMask() {
47         return null;
48     }
49
50     @Override
51     protected String getMaskString() {
52         return null;
53     }
54
55     @Override
56     public boolean isValid() {
57         return vlanPriority >= 0 && vlanPriority <= MAX;
58     }
59
60     @Override
61     public boolean hasReverse() {
62         return false;
63     }
64
65     @Override
66     public DlVlanPriority getReverse() {
67         return this.clone();
68     }
69
70     @Override
71     public DlVlanPriority clone() {
72         return new DlVlanPriority(vlanPriority);
73     }
74
75     @Override
76     public boolean isV6() {
77         return true;
78     }
79
80     @Override
81     public int hashCode() {
82         final int prime = 31;
83         int result = 1;
84         result = prime * result + vlanPriority;
85         return result;
86     }
87
88     @Override
89     public boolean equals(Object obj) {
90         if (this == obj) {
91             return true;
92         }
93         if (obj == null) {
94             return false;
95         }
96         if (!(obj instanceof DlVlanPriority)) {
97             return false;
98         }
99         DlVlanPriority other = (DlVlanPriority) obj;
100         if (vlanPriority != other.vlanPriority) {
101             return false;
102         }
103         return true;
104     }
105 }