blob: c1493d0cb456b91d9539ad62cabbf18c5b18533a [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
41 */
42 public DHCPOption setCode(final byte code) {
43 this.code = code;
44 return this;
45 }
46
47 /**
48 * @return the length
49 */
50 public byte getLength() {
51 return this.length;
52 }
53
54 /**
55 * @param length
56 * the length to set
57 */
58 public DHCPOption setLength(final byte length) {
59 this.length = length;
60 return this;
61 }
62
63 /**
64 * @return the data
65 */
66 public byte[] getData() {
67 return this.data;
68 }
69
70 /**
71 * @param data
72 * the data to set
73 */
74 public DHCPOption setData(final byte[] data) {
75 this.data = data;
76 return this;
77 }
78
79 /*
80 * (non-Javadoc)
81 *
82 * @see java.lang.Object#hashCode()
83 */
84 @Override
85 public int hashCode() {
86 final int prime = 31;
87 int result = 1;
88 result = prime * result + this.code;
89 result = prime * result + Arrays.hashCode(this.data);
90 result = prime * result + this.length;
91 return result;
92 }
93
94 /*
95 * (non-Javadoc)
96 *
97 * @see java.lang.Object#equals(java.lang.Object)
98 */
99 @Override
100 public boolean equals(final Object obj) {
101 if (this == obj) {
102 return true;
103 }
104 if (obj == null) {
105 return false;
106 }
107 if (!(obj instanceof DHCPOption)) {
108 return false;
109 }
110 final DHCPOption other = (DHCPOption) obj;
111 if (this.code != other.code) {
112 return false;
113 }
114 if (!Arrays.equals(this.data, other.data)) {
115 return false;
116 }
117 if (this.length != other.length) {
118 return false;
119 }
120 return true;
121 }
122
123 /*
124 * (non-Javadoc)
125 *
126 * @see java.lang.Object#toString()
127 */
128 @Override
129 public String toString() {
130 return "DHCPOption [code=" + this.code + ", length=" + this.length
131 + ", data=" + Arrays.toString(this.data) + "]";
132 }
133}