Merge "BUG-2218: Keep existing link augmentations during discovery process"
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / match / extensible / InPort.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.core.NodeConnector;
9
10 @XmlRootElement
11 @XmlAccessorType(XmlAccessType.NONE)
12 public class InPort extends MatchField<NodeConnector> {
13     private static final long serialVersionUID = 1L;
14     public static final String TYPE = "IN_PORT";
15     private NodeConnector port;
16
17     /**
18      * Creates a Match field for the input port
19      *
20      * @param port
21      *            the input port
22      */
23     public InPort(NodeConnector port) {
24         super(TYPE);
25         this.port = port;
26     }
27
28     // To satisfy JAXB
29     private InPort() {
30         super(TYPE);
31     }
32
33     @Override
34     public NodeConnector getValue() {
35         return port;
36     }
37
38     @Override
39     @XmlElement(name = "value")
40     protected String getValueString() {
41         return port.toString();
42     }
43
44     @Override
45     public NodeConnector 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 boolean hasReverse() {
61         return false;
62     }
63
64     @Override
65     public InPort getReverse() {
66         return this.clone();
67     }
68
69     @Override
70     public InPort clone() {
71         return new InPort(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 = 1;
83         result = prime * result + ((port == null) ? 0 : port.hashCode());
84         return result;
85     }
86
87     @Override
88     public boolean equals(Object obj) {
89         if (this == obj) {
90             return true;
91         }
92         if (obj == null) {
93             return false;
94         }
95         if (!(obj instanceof InPort)) {
96             return false;
97         }
98         InPort other = (InPort) obj;
99         if (port == null) {
100             if (other.port != null) {
101                 return false;
102             }
103         } else if (!port.equals(other.port)) {
104             return false;
105         }
106         return true;
107     }
108 }