1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.owasp.dependencycheck.dependency.naming;
19
20 import javax.annotation.concurrent.ThreadSafe;
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 import org.owasp.dependencycheck.dependency.Confidence;
26
27
28
29
30
31
32 @ThreadSafe
33 public class GenericIdentifier implements Identifier {
34
35
36
37
38 private static final long serialVersionUID = 8683243972735598200L;
39
40
41
42
43 private Confidence confidence;
44
45
46
47 private final String value;
48
49
50
51 private String url;
52
53
54
55
56 private String notes;
57
58
59
60
61
62
63
64 public GenericIdentifier(String value, Confidence confidence) {
65 this.confidence = confidence;
66 this.value = value;
67 this.url = null;
68 }
69
70
71
72
73
74
75
76
77 public GenericIdentifier(String value, String url, Confidence confidence) {
78 this.confidence = confidence;
79 this.value = value;
80 this.url = url;
81 }
82
83
84
85
86 @Override
87 public Confidence getConfidence() {
88 return confidence;
89 }
90
91
92
93
94 @Override
95 public String getValue() {
96 return value;
97 }
98
99
100
101
102 @Override
103 public String getUrl() {
104 return url;
105 }
106
107
108
109
110 @Override
111 public String getNotes() {
112 return notes;
113 }
114
115
116
117
118 @Override
119 public void setConfidence(Confidence confidence) {
120 this.confidence = confidence;
121 }
122
123
124
125
126 @Override
127 public void setUrl(String url) {
128 this.url = url;
129 }
130
131
132
133
134 @Override
135 public void setNotes(String notes) {
136 this.notes = notes;
137 }
138
139
140
141
142
143
144
145 @Override
146 public boolean equals(Object obj) {
147 if (obj == null || !(obj instanceof GenericIdentifier)) {
148 return false;
149 }
150 if (this == obj) {
151 return true;
152 }
153 final GenericIdentifier other = (GenericIdentifier) obj;
154 return new EqualsBuilder()
155 .append(this.value, other.value)
156 .append(this.url, other.url)
157 .append(this.confidence, other.confidence)
158 .isEquals();
159 }
160
161
162
163
164
165
166 @Override
167 public int hashCode() {
168 return new HashCodeBuilder(5, 49)
169 .append(value)
170 .append(url)
171 .append(confidence)
172 .toHashCode();
173 }
174
175
176
177
178
179
180 @Override
181 public String toString() {
182 return value;
183 }
184
185
186
187
188
189
190
191 @Override
192 public int compareTo(@NotNull Identifier o) {
193 return new CompareToBuilder()
194 .append(this.value, o.toString())
195 .append(this.url, o.getUrl())
196 .append(this.confidence, o.getConfidence())
197 .toComparison();
198 }
199 }