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 java.io.Serializable;
21 import javax.annotation.concurrent.ThreadSafe;
22 import org.apache.commons.lang3.builder.CompareToBuilder;
23 import org.apache.commons.lang3.builder.EqualsBuilder;
24 import org.apache.commons.lang3.builder.HashCodeBuilder;
25 import org.jetbrains.annotations.NotNull;
26
27
28
29
30
31
32
33 @ThreadSafe
34 public class Reference implements Serializable, Comparable<Reference> {
35
36
37
38
39 private static final long serialVersionUID = -3444464824563008021L;
40
41
42
43 private String name;
44
45
46
47 private String url;
48
49
50
51 private String source;
52
53
54
55
56 public Reference() {
57 }
58
59
60
61
62
63
64
65
66 public Reference(String name, String source, String url) {
67 this.name = name;
68 this.source = source;
69 this.url = url;
70 }
71
72
73
74
75
76
77 public String getName() {
78 return name;
79 }
80
81
82
83
84
85
86 public void setName(String name) {
87 this.name = name;
88 }
89
90
91
92
93
94
95 public String getUrl() {
96 return url;
97 }
98
99
100
101
102
103
104 public void setUrl(String url) {
105 this.url = url;
106 }
107
108
109
110
111
112
113 public String getSource() {
114 return source;
115 }
116
117
118
119
120
121
122 public void setSource(String source) {
123 this.source = source;
124 }
125
126 @Override
127 public String toString() {
128 return "Reference: { name='" + this.name + "', url='" + this.url + "', source='" + this.source + "' }";
129 }
130
131 @Override
132 public boolean equals(Object obj) {
133 if (obj == null || !(obj instanceof Reference)) {
134 return false;
135 }
136 if (this == obj) {
137 return true;
138 }
139 final Reference rhs = (Reference) obj;
140 return new EqualsBuilder()
141 .append(source, rhs.source)
142 .append(name, rhs.name)
143 .append(url, rhs.url)
144 .isEquals();
145 }
146
147 @Override
148 public int hashCode() {
149 return new HashCodeBuilder(5, 67)
150 .append(source)
151 .append(name)
152 .append(url)
153 .toHashCode();
154 }
155
156
157
158
159
160
161
162 @Override
163 public int compareTo(@NotNull Reference o) {
164 return new CompareToBuilder()
165 .append(source, o.source)
166 .append(name, o.name)
167 .append(url, o.url)
168 .toComparison();
169 }
170 }