Initial opendaylight infrastructure commit!!
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / action / OFActionTransportLayer.java
1 /**
2  * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
3  */
4 package org.openflow.protocol.action;
5
6 import java.nio.ByteBuffer;
7
8 /**
9  * Represents an ofp_action_tp_port
10  * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
11  */
12 public abstract class OFActionTransportLayer extends OFAction {
13     public static int MINIMUM_LENGTH = 8;
14
15     protected short transportPort;
16
17     /**
18      * @return the transportPort
19      */
20     public short getTransportPort() {
21         return transportPort;
22     }
23
24     /**
25      * @param transportPort the transportPort to set
26      */
27     public void setTransportPort(short transportPort) {
28         this.transportPort = transportPort;
29     }
30
31     @Override
32     public void readFrom(ByteBuffer data) {
33         super.readFrom(data);
34         this.transportPort = data.getShort();
35         data.getShort();
36     }
37
38     @Override
39     public void writeTo(ByteBuffer data) {
40         super.writeTo(data);
41         data.putShort(this.transportPort);
42         data.putShort((short) 0);
43     }
44
45     @Override
46     public int hashCode() {
47         final int prime = 373;
48         int result = super.hashCode();
49         result = prime * result + transportPort;
50         return result;
51     }
52
53     @Override
54     public boolean equals(Object obj) {
55         if (this == obj) {
56             return true;
57         }
58         if (!super.equals(obj)) {
59             return false;
60         }
61         if (!(obj instanceof OFActionTransportLayer)) {
62             return false;
63         }
64         OFActionTransportLayer other = (OFActionTransportLayer) obj;
65         if (transportPort != other.transportPort) {
66             return false;
67         }
68         return true;
69     }
70 }