Fix checkstyle warnings in netconf-cli
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / statistics / OFVendorStatistics.java
1 package org.openflow.protocol.statistics;
2
3 import java.io.Serializable;
4 import java.nio.ByteBuffer;
5
6 import org.openflow.protocol.factory.OFActionFactory;
7 import org.openflow.protocol.factory.OFActionFactoryAware;
8
9 /**
10  * The base class for vendor implemented statistics
11  * @author David Erickson (daviderickson@cs.stanford.edu)
12  */
13 public class OFVendorStatistics implements OFStatistics, OFActionFactoryAware, Serializable {
14     protected transient OFActionFactory actionFactory;
15     protected int vendor;
16     protected byte[] body;
17
18     // non-message fields
19     protected int length = 0;
20
21     @Override
22     public void readFrom(ByteBuffer data) {
23         this.vendor = data.getInt();
24         if (body == null)
25             body = new byte[length - 4];
26         data.get(body);
27     }
28
29     @Override
30     public void writeTo(ByteBuffer data) {
31         data.putInt(this.vendor);
32         if (body != null)
33             data.put(body);
34     }
35
36     @Override
37     public int hashCode() {
38         final int prime = 457;
39         int result = 1;
40         result = prime * result + vendor;
41         return result;
42     }
43
44     @Override
45     public boolean equals(Object obj) {
46         if (this == obj) {
47             return true;
48         }
49         if (obj == null) {
50             return false;
51         }
52         if (!(obj instanceof OFVendorStatistics)) {
53             return false;
54         }
55         OFVendorStatistics other = (OFVendorStatistics) obj;
56         if (vendor != other.vendor) {
57             return false;
58         }
59         return true;
60     }
61
62     @Override
63     public int getLength() {
64         return length;
65     }
66
67     public void setLength(int length) {
68         this.length = length;
69     }
70
71     /**
72      * @param actionFactory the actionFactory to set
73      */
74     @Override
75     public void setActionFactory(OFActionFactory actionFactory) {
76         this.actionFactory = actionFactory;
77     }
78
79     public OFActionFactory getActionFactory() {
80         return this.actionFactory;
81     }
82
83 }