1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.coap;
21
22 import java.util.Arrays;
23
24
25
26
27
28
29 public class CoapOption {
30
31 private final CoapOptionType type;
32
33 private final byte[] data;
34
35
36
37
38
39
40
41 public CoapOption(CoapOptionType type, byte[] data) {
42 super();
43 this.type = type;
44 this.data = Arrays.copyOf(data, data.length);
45 }
46
47 public CoapOptionType getType() {
48 return type;
49 }
50
51 public byte[] getData() {
52 return data;
53 }
54
55
56
57
58 @Override
59 public String toString() {
60 StringBuilder builder = new StringBuilder();
61 builder.append("CoapOption [type=").append(type).append(", data=").append(Arrays.toString(data)).append("]");
62 return builder.toString();
63 }
64
65
66
67
68 @Override
69 public int hashCode() {
70 final int prime = 31;
71 int result = 1;
72 result = prime * result + Arrays.hashCode(data);
73 result = prime * result + ((type == null) ? 0 : type.hashCode());
74 return result;
75 }
76
77
78
79
80 @Override
81 public boolean equals(Object obj) {
82 if (this == obj) {
83 return true;
84 }
85
86 if (obj == null) {
87 return false;
88 }
89
90 if (getClass() != obj.getClass()) {
91 return false;
92 }
93
94 CoapOption other = (CoapOption) obj;
95
96 if (!Arrays.equals(data, other.data)) {
97 return false;
98 }
99
100 if (type != other.type) {
101 return false;
102 }
103
104 return true;
105 }
106 }