blob: 1b6c670ecd6184ab52b8a31ba40ea1ef863b3d33 [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
alshabibc4901cd2014-09-05 16:50:40 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
alshabibc4901cd2014-09-05 16:50:40 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska24c849c2014-10-27 09:53:05 -070015 */
16
17
alshabibc4901cd2014-09-05 16:50:40 -070018
19package org.onlab.packet;
20
21import java.util.Arrays;
22
23/**
24 *
alshabibc4901cd2014-09-05 16:50:40 -070025 */
26public class DHCPOption {
27 protected byte code;
28 protected byte length;
29 protected byte[] data;
30
31 /**
32 * @return the code
33 */
34 public byte getCode() {
35 return this.code;
36 }
37
38 /**
39 * @param code
40 * the code to set
Yuta HIGUCHI2281b3f2014-11-04 00:20:48 -080041 * @return this
alshabibc4901cd2014-09-05 16:50:40 -070042 */
43 public DHCPOption setCode(final byte code) {
44 this.code = code;
45 return this;
46 }
47
48 /**
49 * @return the length
50 */
51 public byte getLength() {
52 return this.length;
53 }
54
55 /**
56 * @param length
57 * the length to set
Yuta HIGUCHI2281b3f2014-11-04 00:20:48 -080058 * @return this
alshabibc4901cd2014-09-05 16:50:40 -070059 */
60 public DHCPOption setLength(final byte length) {
61 this.length = length;
62 return this;
63 }
64
65 /**
66 * @return the data
67 */
68 public byte[] getData() {
69 return this.data;
70 }
71
72 /**
73 * @param data
74 * the data to set
Yuta HIGUCHI2281b3f2014-11-04 00:20:48 -080075 * @return this
alshabibc4901cd2014-09-05 16:50:40 -070076 */
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}