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 / TpDst.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 TpDst extends MatchField<Short> {
13     private static final long serialVersionUID = 1L;
14     public static final String TYPE = "TP_DST";
15     private short port;
16
17     /**
18      * Creates a Match field for the transport destination port
19      *
20      * @param port
21      *            the transport port
22      */
23     public TpDst(short port) {
24         super(TYPE);
25         this.port = port;
26     }
27
28     // To satisfy JAXB
29     private TpDst() {
30         super(TYPE);
31     }
32
33     @Override
34     public Short getValue() {
35         return port;
36     }
37
38     @Override
39     @XmlElement(name = "value")
40     protected String getValueString() {
41         return String.valueOf(NetUtils.getUnsignedShort(port));
42     }
43
44     @Override
45     public Short getMask() {
46         return null;
47     }
48
49     @Override
50     protected String getMaskString() {
51         return null;
52     }
53
54     @Override
55     public boolean isValid() {
56         return true;
57     }
58
59     @Override
60     public TpSrc getReverse() {
61         return new TpSrc(port);
62     }
63
64     @Override
65     public boolean hasReverse() {
66         return true;
67     }
68
69     @Override
70     public TpDst clone() {
71         return new TpDst(port);
72     }
73
74     @Override
75     public boolean isV6() {
76         return true;
77     }
78
79     @Override
80     public int hashCode() {
81         final int prime = 31;
82         int result = super.hashCode();
83         result = prime * result + port;
84         return result;
85     }
86
87     @Override
88     public boolean equals(Object obj) {
89         if (this == obj) {
90             return true;
91         }
92         if (!super.equals(obj)) {
93             return false;
94         }
95         if (!(obj instanceof TpDst)) {
96             return false;
97         }
98         TpDst other = (TpDst) obj;
99         if (port != other.port) {
100             return false;
101         }
102         return true;
103     }
104 }