1 package org.openflow.codec.protocol.instruction;
3 import java.io.Serializable;
5 import org.openflow.codec.io.IDataBuffer;
6 import org.openflow.codec.util.U16;
9 * correspond to struct ofp_instruction openflow structure Instruction header
10 * that is common to all instructions. The length field includes the header and
11 * any padding used to make the instruction 64-bit aligned.
16 public class OFPInstruction implements Cloneable, Serializable {
18 private static final long serialVersionUID = 1L;
20 public static final short MINIMUM_LENGTH = 4;
22 protected short length;
23 protected OFPInstructionType type;
26 * get the length of instruction structure
30 public short getLength() {
35 * set the length of instruction structure
39 public void setLength(short length) {
44 * get the unsigned length of instruction structure
48 public int getLengthU() {
53 * get the OFInstrutionType
57 public OFPInstructionType getOFInstructionType() {
62 * set the OFPInstructionType
66 public void setOFInstructionType(OFPInstructionType type) {
71 * read OFPInstruction object state from buffer
75 public void readFrom(IDataBuffer data) {
76 this.type = OFPInstructionType.valueOf(data.getShort());
77 this.length = data.getShort();
81 * write OFPInstruction object state to buffer
85 public void writeTo(IDataBuffer data) {
86 data.putShort(type.getTypeValue());
87 data.putShort(this.length);
92 public int hashCode() {
93 final int prime = 741;
95 result = prime * result + length;
96 result = prime * result + ((type == null) ? 0 : type.hashCode());
101 public boolean equals(Object obj) {
108 if (!(obj instanceof OFPInstruction)) {
111 OFPInstruction other = (OFPInstruction) obj;
112 if (length != other.length) {
116 if (other.type != null) {
119 } else if (!type.equals(other.type)) {
128 * @see java.lang.Object#clone()
131 public OFPInstruction clone() throws CloneNotSupportedException {
132 return (OFPInstruction) super.clone();