1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.owasp.dependencycheck.dependency;
19
20 import org.apache.commons.lang3.StringUtils;
21 import org.apache.commons.lang3.builder.CompareToBuilder;
22 import org.apache.commons.lang3.builder.EqualsBuilder;
23 import org.apache.commons.lang3.builder.HashCodeBuilder;
24 import org.jetbrains.annotations.NotNull;
25
26 import java.io.Serializable;
27 import javax.annotation.concurrent.ThreadSafe;
28
29
30
31
32
33
34 @ThreadSafe
35 public class Evidence implements Serializable, Comparable<Evidence> {
36
37
38
39
40 private static final long serialVersionUID = 2402386455919067874L;
41
42
43
44
45 private String name;
46
47
48
49
50 private String source;
51
52
53
54
55 private String value;
56
57
58
59
60 private Confidence confidence;
61
62
63
64
65 private boolean fromHint;
66
67
68
69
70 public Evidence() {
71 }
72
73
74
75
76
77
78
79
80
81 public Evidence(String source, String name, String value, Confidence confidence) {
82 this(source, name, value, confidence, false);
83 }
84
85
86
87
88
89
90
91
92
93
94 public Evidence(String source, String name, String value, Confidence confidence, boolean fromHint) {
95 this.source = source;
96 this.name = name;
97 this.value = value;
98 this.confidence = confidence;
99 this.fromHint = fromHint;
100 }
101
102
103
104
105
106
107 public String getName() {
108 return name;
109 }
110
111
112
113
114
115
116 public void setName(String name) {
117 this.name = name;
118 }
119
120
121
122
123
124
125 public String getSource() {
126 return source;
127 }
128
129
130
131
132
133
134 public void setSource(String source) {
135 this.source = source;
136 }
137
138
139
140
141
142
143 public String getValue() {
144 return value;
145 }
146
147
148
149
150
151
152 public void setValue(String value) {
153 this.value = value;
154 }
155
156
157
158
159
160
161 public Confidence getConfidence() {
162 return confidence;
163 }
164
165
166
167
168
169
170 public void setConfidence(Confidence confidence) {
171 this.confidence = confidence;
172 }
173
174
175
176
177
178
179 public boolean isFromHint() {
180 return fromHint;
181 }
182
183
184
185
186
187
188 public void setFromHint(boolean fromHint) {
189 this.fromHint = fromHint;
190 }
191
192
193
194
195
196
197 @Override
198 public int hashCode() {
199 return new HashCodeBuilder(303, 367)
200 .append(StringUtils.lowerCase(name))
201 .append(StringUtils.lowerCase(source))
202 .append(StringUtils.lowerCase(value))
203 .append(confidence)
204 .toHashCode();
205 }
206
207
208
209
210
211
212
213 @Override
214 public boolean equals(Object obj) {
215 if (obj == null || !(obj instanceof Evidence)) {
216 return false;
217 }
218 if (this == obj) {
219 return true;
220 }
221 final Evidence o = (Evidence) obj;
222 return new EqualsBuilder()
223 .append(this.source == null ? null : this.source.toLowerCase(), o.source == null ? null : o.source.toLowerCase())
224 .append(this.name == null ? null : this.name.toLowerCase(), o.name == null ? null : o.name.toLowerCase())
225 .append(this.value == null ? null : this.value.toLowerCase(), o.value == null ? null : o.value.toLowerCase())
226 .append(this.confidence, o.getConfidence())
227 .append(this.fromHint, o.isFromHint())
228 .build();
229 }
230
231
232
233
234
235
236
237 @Override
238 public int compareTo(@NotNull Evidence o) {
239 return new CompareToBuilder()
240 .append(this.source == null ? null : this.source.toLowerCase(), o.source == null ? null : o.source.toLowerCase())
241 .append(this.name == null ? null : this.name.toLowerCase(), o.name == null ? null : o.name.toLowerCase())
242 .append(this.value == null ? null : this.value.toLowerCase(), o.value == null ? null : o.value.toLowerCase())
243 .append(this.confidence, o.getConfidence())
244 .append(this.fromHint, o.isFromHint())
245 .toComparison();
246 }
247
248
249
250
251
252
253 @Override
254 public String toString() {
255 return "Evidence{" + "name=" + name + ", source=" + source + ", value=" + value + ", confidence=" + confidence
256 + ", fromHint=" + fromHint + '}';
257 }
258 }