Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / match / extensible / NwTos.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 @Deprecated
13 public class NwTos extends MatchField<Byte> {
14     private static final long serialVersionUID = 1L;
15     public static final String TYPE = "NW_TOS";
16     private static final short MAX = 63;
17     private byte tos;
18
19     /**
20      * Creates a Match field for the network TOS
21      *
22      * @param address
23      *            the network TOS
24      */
25     public NwTos(byte tos) {
26         super(TYPE);
27         this.tos = tos;
28     }
29
30     public NwTos(int tos) {
31         super(TYPE);
32         this.tos = (byte) tos;
33     }
34
35     public NwTos(short tos) {
36         super(TYPE);
37         this.tos = (byte) tos;
38     }
39
40     // To satisfy JAXB
41     private NwTos() {
42         super(TYPE);
43     }
44
45     @Override
46     public Byte getValue() {
47         return tos;
48     }
49
50     @Override
51     @XmlElement(name = "value")
52     protected String getValueString() {
53         return String.format("0X%s", Integer.toHexString(NetUtils.getUnsignedByte(tos)));
54     }
55
56     @Override
57     public Byte getMask() {
58         return null;
59     }
60
61     @Override
62     protected String getMaskString() {
63         return null;
64     }
65
66     @Override
67     public boolean isValid() {
68         return tos >= 0 && tos <= MAX;
69     }
70
71     @Override
72     public boolean hasReverse() {
73         return false;
74     }
75
76     @Override
77     public NwTos getReverse() {
78         return this.clone();
79     }
80
81     @Override
82     public NwTos clone() {
83         return new NwTos(tos);
84     }
85
86     @Override
87     public boolean isV6() {
88         return true;
89     }
90
91     @Override
92     public int hashCode() {
93         final int prime = 31;
94         int result = 1;
95         result = prime * result + tos;
96         return result;
97     }
98
99     @Override
100     public boolean equals(Object obj) {
101         if (this == obj) {
102             return true;
103         }
104         if (obj == null) {
105             return false;
106         }
107         if (!(obj instanceof NwTos)) {
108             return false;
109         }
110         NwTos other = (NwTos) obj;
111         if (tos != other.tos) {
112             return false;
113         }
114         return true;
115     }
116 }