Skip to content

Commit e554212

Browse files
committed
Add missing equals and hashCode
1 parent 735587a commit e554212

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1450
-0
lines changed

src/main/java/org/cyclonedx/model/Attribute.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.cyclonedx.model;
2020

21+
import java.util.Objects;
22+
2123
public class Attribute {
2224

2325
private final String key;
@@ -36,4 +38,20 @@ public String getValue() {
3638
return this.value;
3739
}
3840

41+
@Override
42+
public boolean equals(final Object object) {
43+
if (this == object) {
44+
return true;
45+
}
46+
if (!(object instanceof Attribute)) {
47+
return false;
48+
}
49+
Attribute attribute = (Attribute) object;
50+
return Objects.equals(key, attribute.key) && Objects.equals(value, attribute.value);
51+
}
52+
53+
@Override
54+
public int hashCode() {
55+
return Objects.hash(key, value);
56+
}
3957
}

src/main/java/org/cyclonedx/model/Composition.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import java.util.ArrayList;
3131
import java.util.List;
32+
import java.util.Objects;
3233

3334
@JsonIgnoreProperties(ignoreUnknown = true)
3435
@JsonInclude(Include.NON_EMPTY)
@@ -142,4 +143,24 @@ public void addVulnerability(BomReference vulnerability) {
142143
}
143144
vulnerabilities.add(vulnerability);
144145
}
146+
147+
@Override
148+
public boolean equals(final Object object) {
149+
if (this == object) {
150+
return true;
151+
}
152+
if (!(object instanceof Composition)) {
153+
return false;
154+
}
155+
Composition that = (Composition) object;
156+
return Objects.equals(bomRef, that.bomRef) && aggregate == that.aggregate &&
157+
Objects.equals(assemblies, that.assemblies) &&
158+
Objects.equals(dependencies, that.dependencies) &&
159+
Objects.equals(vulnerabilities, that.vulnerabilities);
160+
}
161+
162+
@Override
163+
public int hashCode() {
164+
return Objects.hash(bomRef, aggregate, assemblies, dependencies, vulnerabilities);
165+
}
145166
}

src/main/java/org/cyclonedx/model/Copyright.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.cyclonedx.model;
2020

21+
import java.util.Objects;
22+
2123
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2224
import com.fasterxml.jackson.annotation.JsonInclude;
2325
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@@ -42,4 +44,21 @@ public String getText() {
4244
public void setText(String text) {
4345
this.text = text;
4446
}
47+
48+
@Override
49+
public boolean equals(final Object object) {
50+
if (this == object) {
51+
return true;
52+
}
53+
if (!(object instanceof Copyright)) {
54+
return false;
55+
}
56+
Copyright copyright = (Copyright) object;
57+
return Objects.equals(text, copyright.text);
58+
}
59+
60+
@Override
61+
public int hashCode() {
62+
return Objects.hashCode(text);
63+
}
4564
}

src/main/java/org/cyclonedx/model/Diff.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.cyclonedx.model;
2020

21+
import java.util.Objects;
22+
2123
public class Diff {
2224

2325
private AttachmentText text;
@@ -38,4 +40,21 @@ public String getUrl() {
3840
public void setUrl(final String url) {
3941
this.url = url;
4042
}
43+
44+
@Override
45+
public boolean equals(final Object object) {
46+
if (this == object) {
47+
return true;
48+
}
49+
if (!(object instanceof Diff)) {
50+
return false;
51+
}
52+
Diff diff = (Diff) object;
53+
return Objects.equals(text, diff.text) && Objects.equals(url, diff.url);
54+
}
55+
56+
@Override
57+
public int hashCode() {
58+
return Objects.hash(text, url);
59+
}
4160
}

src/main/java/org/cyclonedx/model/Evidence.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
import java.util.ArrayList;
3737
import java.util.List;
38+
import java.util.Objects;
3839

3940
@SuppressWarnings("unused")
4041
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -125,4 +126,25 @@ public List<Identity> getIdentities() {
125126
public void setIdentities(final List<Identity> identities) {
126127
this.identities = identities;
127128
}
129+
130+
@Override
131+
public boolean equals(final Object object) {
132+
if (this == object) {
133+
return true;
134+
}
135+
if (!(object instanceof Evidence)) {
136+
return false;
137+
}
138+
Evidence evidence = (Evidence) object;
139+
return Objects.equals(licenses, evidence.licenses) &&
140+
Objects.equals(copyright, evidence.copyright) &&
141+
Objects.equals(identities, evidence.identities) &&
142+
Objects.equals(occurrences, evidence.occurrences) &&
143+
Objects.equals(callstack, evidence.callstack);
144+
}
145+
146+
@Override
147+
public int hashCode() {
148+
return Objects.hash(licenses, copyright, identities, occurrences, callstack);
149+
}
128150
}

src/main/java/org/cyclonedx/model/Issue.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.net.URI;
2828
import java.util.ArrayList;
2929
import java.util.List;
30+
import java.util.Objects;
3031

3132
@JsonIgnoreProperties(ignoreUnknown = true)
3233
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@@ -123,4 +124,23 @@ public Type getType() {
123124
public void setType(Type type) {
124125
this.type = type;
125126
}
127+
128+
@Override
129+
public boolean equals(final Object object) {
130+
if (this == object) {
131+
return true;
132+
}
133+
if (!(object instanceof Issue)) {
134+
return false;
135+
}
136+
Issue issue = (Issue) object;
137+
return Objects.equals(id, issue.id) && Objects.equals(name, issue.name) &&
138+
Objects.equals(description, issue.description) && Objects.equals(source, issue.source) &&
139+
Objects.equals(references, issue.references) && type == issue.type;
140+
}
141+
142+
@Override
143+
public int hashCode() {
144+
return Objects.hash(id, name, description, source, references, type);
145+
}
126146
}

src/main/java/org/cyclonedx/model/LifecycleChoice.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.cyclonedx.model;
2020

21+
import java.util.Objects;
22+
2123
import com.fasterxml.jackson.annotation.JsonCreator;
2224
import com.fasterxml.jackson.annotation.JsonInclude;
2325
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -99,4 +101,22 @@ public Phase getPhase() {
99101
public void setPhase(final Phase phase) {
100102
this.phase = phase;
101103
}
104+
105+
@Override
106+
public boolean equals(final Object object) {
107+
if (this == object) {
108+
return true;
109+
}
110+
if (!(object instanceof LifecycleChoice)) {
111+
return false;
112+
}
113+
LifecycleChoice choice = (LifecycleChoice) object;
114+
return phase == choice.phase && Objects.equals(name, choice.name) &&
115+
Objects.equals(description, choice.description);
116+
}
117+
118+
@Override
119+
public int hashCode() {
120+
return Objects.hash(phase, name, description);
121+
}
102122
}

src/main/java/org/cyclonedx/model/Lifecycles.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.cyclonedx.model;
2020

2121
import java.util.List;
22+
import java.util.Objects;
2223

2324
import com.fasterxml.jackson.annotation.JsonInclude;
2425
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
@@ -36,4 +37,21 @@ public List<LifecycleChoice> getLifecycleChoice() {
3637
public void setLifecycleChoice(final List<LifecycleChoice> lifecycleChoice) {
3738
this.lifecycleChoice = lifecycleChoice;
3839
}
40+
41+
@Override
42+
public boolean equals(final Object object) {
43+
if (this == object) {
44+
return true;
45+
}
46+
if (!(object instanceof Lifecycles)) {
47+
return false;
48+
}
49+
Lifecycles that = (Lifecycles) object;
50+
return Objects.equals(lifecycleChoice, that.lifecycleChoice);
51+
}
52+
53+
@Override
54+
public int hashCode() {
55+
return Objects.hashCode(lifecycleChoice);
56+
}
3957
}

src/main/java/org/cyclonedx/model/Patch.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
package org.cyclonedx.model;
2020

2121
import java.util.List;
22+
import java.util.Objects;
23+
2224
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2325
import com.fasterxml.jackson.annotation.JsonInclude;
2426
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -83,4 +85,22 @@ public Type getType() {
8385
public void setType(Type type) {
8486
this.type = type;
8587
}
88+
89+
@Override
90+
public boolean equals(final Object object) {
91+
if (this == object) {
92+
return true;
93+
}
94+
if (!(object instanceof Patch)) {
95+
return false;
96+
}
97+
Patch patch = (Patch) object;
98+
return type == patch.type && Objects.equals(diff, patch.diff) &&
99+
Objects.equals(resolves, patch.resolves);
100+
}
101+
102+
@Override
103+
public int hashCode() {
104+
return Objects.hash(type, diff, resolves);
105+
}
86106
}

src/main/java/org/cyclonedx/model/ReleaseNotes.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.util.Date;
2222
import java.util.List;
23+
import java.util.Objects;
2324

2425
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2526
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -289,4 +290,28 @@ public void setText(final AttachmentText text) {
289290
this.text = text;
290291
}
291292
}
293+
294+
@Override
295+
public boolean equals(final Object object) {
296+
if (this == object) {
297+
return true;
298+
}
299+
if (!(object instanceof ReleaseNotes)) {
300+
return false;
301+
}
302+
ReleaseNotes that = (ReleaseNotes) object;
303+
return Objects.equals(type, that.type) && Objects.equals(title, that.title) &&
304+
Objects.equals(featuredImage, that.featuredImage) &&
305+
Objects.equals(socialImage, that.socialImage) &&
306+
Objects.equals(description, that.description) && Objects.equals(timestamp, that.timestamp) &&
307+
Objects.equals(aliases, that.aliases) && Objects.equals(tags, that.tags) &&
308+
Objects.equals(resolves, that.resolves) && Objects.equals(notes, that.notes) &&
309+
Objects.equals(properties, that.properties);
310+
}
311+
312+
@Override
313+
public int hashCode() {
314+
return Objects.hash(type, title, featuredImage, socialImage, description, timestamp, aliases, tags, resolves, notes,
315+
properties);
316+
}
292317
}

0 commit comments

Comments
 (0)