Initial opendaylight infrastructure commit!!
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / action / OFActionVirtualLanPriorityCodePoint.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_vlan_pcp
10  * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
11  */
12 public class OFActionVirtualLanPriorityCodePoint extends OFAction {
13     public static int MINIMUM_LENGTH = 8;
14
15     protected byte virtualLanPriorityCodePoint;
16
17     public OFActionVirtualLanPriorityCodePoint() {
18         super.setType(OFActionType.SET_VLAN_PCP);
19         super.setLength((short) MINIMUM_LENGTH);
20     }
21
22     /**
23      * @return the virtualLanPriorityCodePoint
24      */
25     public byte getVirtualLanPriorityCodePoint() {
26         return virtualLanPriorityCodePoint;
27     }
28
29     /**
30      * @param virtualLanPriorityCodePoint the virtualLanPriorityCodePoint to set
31      */
32     public void setVirtualLanPriorityCodePoint(byte virtualLanPriorityCodePoint) {
33         this.virtualLanPriorityCodePoint = virtualLanPriorityCodePoint;
34     }
35
36     @Override
37     public void readFrom(ByteBuffer data) {
38         super.readFrom(data);
39         this.virtualLanPriorityCodePoint = data.get();
40         data.getShort(); // pad
41         data.get(); // pad
42     }
43
44     @Override
45     public void writeTo(ByteBuffer data) {
46         super.writeTo(data);
47         data.put(this.virtualLanPriorityCodePoint);
48         data.putShort((short) 0);
49         data.put((byte) 0);
50     }
51
52     @Override
53     public int hashCode() {
54         final int prime = 389;
55         int result = super.hashCode();
56         result = prime * result + virtualLanPriorityCodePoint;
57         return result;
58     }
59
60     @Override
61     public boolean equals(Object obj) {
62         if (this == obj) {
63             return true;
64         }
65         if (!super.equals(obj)) {
66             return false;
67         }
68         if (!(obj instanceof OFActionVirtualLanPriorityCodePoint)) {
69             return false;
70         }
71         OFActionVirtualLanPriorityCodePoint other = (OFActionVirtualLanPriorityCodePoint) obj;
72         if (virtualLanPriorityCodePoint != other.virtualLanPriorityCodePoint) {
73             return false;
74         }
75         return true;
76     }
77 }