Initial opendaylight infrastructure commit!!
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / OFQueueConfigRequest.java
1 package org.openflow.protocol;
2
3 import java.nio.ByteBuffer;
4
5 import org.openflow.util.U16;
6
7 /**
8  *
9  * @author David Erickson (daviderickson@cs.stanford.edu)
10  */
11 public class OFQueueConfigRequest extends OFMessage implements Cloneable {
12     public static int MINIMUM_LENGTH = 12;
13
14     protected short port;
15
16     /**
17      * 
18      */
19     public OFQueueConfigRequest() {
20         super();
21         this.type = OFType.QUEUE_CONFIG_REQUEST;
22         this.length = U16.t(MINIMUM_LENGTH);
23     }
24
25     /**
26      * @return the port
27      */
28     public short getPort() {
29         return port;
30     }
31
32     /**
33      * @param port the port to set
34      */
35     public void setPort(short port) {
36         this.port = port;
37     }
38
39     @Override
40     public void readFrom(ByteBuffer data) {
41         super.readFrom(data);
42         this.port = data.getShort();
43         data.get(); // pad
44         data.get(); // pad
45     }
46
47     @Override
48     public void writeTo(ByteBuffer data) {
49         super.writeTo(data);
50         data.putShort(this.port);
51         data.putShort((short) 0); // pad
52     }
53
54     @Override
55     public int hashCode() {
56         final int prime = 7211;
57         int result = super.hashCode();
58         result = prime * result + port;
59         return result;
60     }
61
62     @Override
63     public boolean equals(Object obj) {
64         if (this == obj)
65             return true;
66         if (!super.equals(obj))
67             return false;
68         if (!(obj instanceof OFQueueConfigRequest))
69             return false;
70         OFQueueConfigRequest other = (OFQueueConfigRequest) obj;
71         if (port != other.port)
72             return false;
73         return true;
74     }
75
76     @Override
77     public OFQueueConfigRequest clone() {
78         try {
79             return (OFQueueConfigRequest) super.clone();
80         } catch (CloneNotSupportedException e) {
81             throw new RuntimeException(e);
82         }
83     }
84 }