0ca682d51e0b285b1866940ea28d4542c7bd9cae
[openflowjava.git] / third-party / openflow-codec / src / main / java / org / openflow / codec / protocol / action / OFPActionPush.java
1 /**
2  * @author Yugandhar Sarraju (ysarraju@in.ibm.com) - July 20, 2013
3  */
4 package org.openflow.codec.protocol.action;
5
6 import org.openflow.codec.io.IDataBuffer;
7
8 /**
9  * Represents an action struct ofp_action_push
10  */
11 public class OFPActionPush extends OFPAction {
12     public static int MINIMUM_LENGTH = 8;
13
14     protected short etherType;
15
16     /**
17      * @return the etherType
18      */
19     public short getEtherType() {
20         return etherType;
21     }
22
23     /**
24      * @param etherType
25      *            the etherType to set
26      */
27     public void setEtherType(short etherType) {
28         this.etherType = etherType;
29     }
30
31     @Override
32     public void readFrom(IDataBuffer data) {
33         super.readFrom(data);
34         this.etherType = data.getShort();
35         data.getShort();
36     }
37
38     @Override
39     public void writeTo(IDataBuffer data) {
40         super.writeTo(data);
41         data.putShort(this.etherType);
42         data.putShort((short) 0);
43     }
44
45     @Override
46     public int hashCode() {
47         final int prime = 389;
48         int result = super.hashCode();
49         result = prime * result + etherType;
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 OFPActionPush)) {
62             return false;
63         }
64         OFPActionPush other = (OFPActionPush) obj;
65         if (etherType != other.etherType) {
66             return false;
67         }
68         return true;
69     }
70 }