blob: 02f27fec242eb240f8de4427b57ea37775f18611 [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
alshabibc4901cd2014-09-05 16:50:40 -07009 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
Thomas Vachuska24c849c2014-10-27 09:53:05 -070012 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
alshabibc4901cd2014-09-05 16:50:40 -070017 * under the License.
Thomas Vachuska24c849c2014-10-27 09:53:05 -070018 */
19
20
alshabibc4901cd2014-09-05 16:50:40 -070021
22package org.onlab.packet;
23
24import java.util.Arrays;
25
26/**
27 *
alshabibc4901cd2014-09-05 16:50:40 -070028 */
29public class DHCPOption {
30 protected byte code;
31 protected byte length;
32 protected byte[] data;
33
34 /**
35 * @return the code
36 */
37 public byte getCode() {
38 return this.code;
39 }
40
41 /**
42 * @param code
43 * the code to set
44 */
45 public DHCPOption setCode(final byte code) {
46 this.code = code;
47 return this;
48 }
49
50 /**
51 * @return the length
52 */
53 public byte getLength() {
54 return this.length;
55 }
56
57 /**
58 * @param length
59 * the length to set
60 */
61 public DHCPOption setLength(final byte length) {
62 this.length = length;
63 return this;
64 }
65
66 /**
67 * @return the data
68 */
69 public byte[] getData() {
70 return this.data;
71 }
72
73 /**
74 * @param data
75 * the data to set
76 */
77 public DHCPOption setData(final byte[] data) {
78 this.data = data;
79 return this;
80 }
81
82 /*
83 * (non-Javadoc)
84 *
85 * @see java.lang.Object#hashCode()
86 */
87 @Override
88 public int hashCode() {
89 final int prime = 31;
90 int result = 1;
91 result = prime * result + this.code;
92 result = prime * result + Arrays.hashCode(this.data);
93 result = prime * result + this.length;
94 return result;
95 }
96
97 /*
98 * (non-Javadoc)
99 *
100 * @see java.lang.Object#equals(java.lang.Object)
101 */
102 @Override
103 public boolean equals(final Object obj) {
104 if (this == obj) {
105 return true;
106 }
107 if (obj == null) {
108 return false;
109 }
110 if (!(obj instanceof DHCPOption)) {
111 return false;
112 }
113 final DHCPOption other = (DHCPOption) obj;
114 if (this.code != other.code) {
115 return false;
116 }
117 if (!Arrays.equals(this.data, other.data)) {
118 return false;
119 }
120 if (this.length != other.length) {
121 return false;
122 }
123 return true;
124 }
125
126 /*
127 * (non-Javadoc)
128 *
129 * @see java.lang.Object#toString()
130 */
131 @Override
132 public String toString() {
133 return "DHCPOption [code=" + this.code + ", length=" + this.length
134 + ", data=" + Arrays.toString(this.data) + "]";
135 }
136}