Initial opendaylight infrastructure commit!!
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / statistics / OFDescriptionStatistics.java
1 package org.openflow.protocol.statistics;
2
3 import java.io.Serializable;
4 import java.nio.ByteBuffer;
5
6 import org.openflow.util.StringByteSerializer;
7
8 /**
9  * Represents an ofp_desc_stats structure
10  * @author David Erickson (daviderickson@cs.stanford.edu)
11  */
12 public class OFDescriptionStatistics implements OFStatistics, Serializable {
13     public static int DESCRIPTION_STRING_LENGTH = 256;
14     public static int SERIAL_NUMBER_LENGTH = 32;
15
16     protected String manufacturerDescription;
17     protected String hardwareDescription;
18     protected String softwareDescription;
19     protected String serialNumber;
20     protected String datapathDescription;
21
22     /**
23      * @return the manufacturerDescription
24      */
25     public String getManufacturerDescription() {
26         return manufacturerDescription;
27     }
28
29     /**
30      * @param manufacturerDescription the manufacturerDescription to set
31      */
32     public void setManufacturerDescription(String manufacturerDescription) {
33         this.manufacturerDescription = manufacturerDescription;
34     }
35
36     /**
37      * @return the hardwareDescription
38      */
39     public String getHardwareDescription() {
40         return hardwareDescription;
41     }
42
43     /**
44      * @param hardwareDescription the hardwareDescription to set
45      */
46     public void setHardwareDescription(String hardwareDescription) {
47         this.hardwareDescription = hardwareDescription;
48     }
49
50     /**
51      * @return the softwareDescription
52      */
53     public String getSoftwareDescription() {
54         return softwareDescription;
55     }
56
57     /**
58      * @param softwareDescription the softwareDescription to set
59      */
60     public void setSoftwareDescription(String softwareDescription) {
61         this.softwareDescription = softwareDescription;
62     }
63
64     /**
65      * @return the serialNumber
66      */
67     public String getSerialNumber() {
68         if (serialNumber.equals("None"))
69                 return "";
70         return serialNumber;
71     }
72
73     /**
74      * @param serialNumber the serialNumber to set
75      */
76     public void setSerialNumber(String serialNumber) {
77         this.serialNumber = serialNumber;
78     }
79
80     /**
81      * @return the datapathDescription
82      */
83     public String getDatapathDescription() {
84         return datapathDescription;
85     }
86
87     /**
88      * @param datapathDescription the datapathDescription to set
89      */
90     public void setDatapathDescription(String datapathDescription) {
91         this.datapathDescription = datapathDescription;
92     }
93
94     @Override
95     public int getLength() {
96         return 1056;
97     }
98
99     @Override
100     public void readFrom(ByteBuffer data) {
101         this.manufacturerDescription = StringByteSerializer.readFrom(data,
102                 DESCRIPTION_STRING_LENGTH);
103         this.hardwareDescription = StringByteSerializer.readFrom(data,
104                 DESCRIPTION_STRING_LENGTH);
105         this.softwareDescription = StringByteSerializer.readFrom(data,
106                 DESCRIPTION_STRING_LENGTH);
107         this.serialNumber = StringByteSerializer.readFrom(data,
108                 SERIAL_NUMBER_LENGTH);
109         this.datapathDescription = StringByteSerializer.readFrom(data,
110                 DESCRIPTION_STRING_LENGTH);
111     }
112
113     @Override
114     public void writeTo(ByteBuffer data) {
115         StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH,
116                 this.manufacturerDescription);
117         StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH,
118                 this.hardwareDescription);
119         StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH,
120                 this.softwareDescription);
121         StringByteSerializer.writeTo(data, SERIAL_NUMBER_LENGTH,
122                 this.serialNumber);
123         StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH,
124                 this.datapathDescription);
125     }
126
127     @Override
128     public int hashCode() {
129         final int prime = 409;
130         int result = 1;
131         result = prime
132                 * result
133                 + ((datapathDescription == null) ? 0 : datapathDescription
134                         .hashCode());
135         result = prime
136                 * result
137                 + ((hardwareDescription == null) ? 0 : hardwareDescription
138                         .hashCode());
139         result = prime
140                 * result
141                 + ((manufacturerDescription == null) ? 0
142                         : manufacturerDescription.hashCode());
143         result = prime * result
144                 + ((serialNumber == null) ? 0 : serialNumber.hashCode());
145         result = prime
146                 * result
147                 + ((softwareDescription == null) ? 0 : softwareDescription
148                         .hashCode());
149         return result;
150     }
151
152     @Override
153     public boolean equals(Object obj) {
154         if (this == obj) {
155             return true;
156         }
157         if (obj == null) {
158             return false;
159         }
160         if (!(obj instanceof OFDescriptionStatistics)) {
161             return false;
162         }
163         OFDescriptionStatistics other = (OFDescriptionStatistics) obj;
164         if (datapathDescription == null) {
165             if (other.datapathDescription != null) {
166                 return false;
167             }
168         } else if (!datapathDescription.equals(other.datapathDescription)) {
169             return false;
170         }
171         if (hardwareDescription == null) {
172             if (other.hardwareDescription != null) {
173                 return false;
174             }
175         } else if (!hardwareDescription.equals(other.hardwareDescription)) {
176             return false;
177         }
178         if (manufacturerDescription == null) {
179             if (other.manufacturerDescription != null) {
180                 return false;
181             }
182         } else if (!manufacturerDescription
183                 .equals(other.manufacturerDescription)) {
184             return false;
185         }
186         if (serialNumber == null) {
187             if (other.serialNumber != null) {
188                 return false;
189             }
190         } else if (!serialNumber.equals(other.serialNumber)) {
191             return false;
192         }
193         if (softwareDescription == null) {
194             if (other.softwareDescription != null) {
195                 return false;
196             }
197         } else if (!softwareDescription.equals(other.softwareDescription)) {
198             return false;
199         }
200         return true;
201     }
202 }