452cfa4d52d144311aecf38e89924439fb521bc6
[openflowjava.git] / third-party / openflow-codec / src / main / java / org / openflow / codec / protocol / action / OFPActionGroup.java
1 /**
2  * @author Yugandhar Sarraju (ysarraju@in.ibm.com) - Jul 20, 2013
3  */
4 package org.openflow.codec.protocol.action;
5
6 import org.openflow.codec.io.IDataBuffer;
7
8 /**
9  * Represents an ofp_action_group
10  */
11 public class OFPActionGroup extends OFPAction {
12     public static int MINIMUM_LENGTH = 8;
13
14     protected int groupId;
15
16     public OFPActionGroup() {
17         super.setType(OFPActionType.GROUP);
18         super.setLength((short) MINIMUM_LENGTH);
19     }
20
21     /**
22      * @return the groupId
23      */
24     public int getGroupId() {
25         return groupId;
26     }
27
28     /**
29      * @param groupId
30      *            the groupId to set
31      */
32     public void setGroupId(int groupId) {
33         this.groupId = groupId;
34     }
35
36     @Override
37     public void readFrom(IDataBuffer data) {
38         super.readFrom(data);
39         this.groupId = data.getInt();
40     }
41
42     @Override
43     public void writeTo(IDataBuffer data) {
44         super.writeTo(data);
45         data.putInt(this.groupId);
46     }
47
48     @Override
49     public int hashCode() {
50         final int prime = 353;
51         int result = super.hashCode();
52         result = prime * result + groupId;
53         return result;
54     }
55
56     @Override
57     public boolean equals(Object obj) {
58         if (this == obj) {
59             return true;
60         }
61         if (!super.equals(obj)) {
62             return false;
63         }
64         if (!(obj instanceof OFPActionGroup)) {
65             return false;
66         }
67         OFPActionGroup other = (OFPActionGroup) obj;
68         if (groupId != other.groupId) {
69             return false;
70         }
71         return true;
72     }
73 }