Skip to content

Commit 747f9d9

Browse files
committed
Merge pull request #1956 from zlamalp/fixCandidate
CORE: Fixed Candidate comparison
1 parent 3a24a4b commit 747f9d9

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

perun-base/src/main/java/cz/metacentrum/perun/core/api/Candidate.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,44 @@ public String toString() {
132132
+ attrNew).append("', additionalUserExtSources='").append(additionalUserExtSources).append("']").toString();
133133
}
134134

135+
@Override
136+
public int hashCode() {
137+
final int prime = 31;
138+
int result = 1;
139+
result = prime * result
140+
+ ((attributes == null) ? 0 : attributes.hashCode());
141+
result = prime * result
142+
+ ((userExtSource == null) ? 0 : userExtSource.hashCode());
143+
return result;
144+
}
145+
146+
@Override
147+
public boolean equals(Object obj) {
148+
if (this == obj) {
149+
return true;
150+
}
151+
if (obj == null) {
152+
return false;
153+
}
154+
if (getClass() != obj.getClass()) {
155+
return false;
156+
}
157+
Candidate other = (Candidate) obj;
158+
if (attributes == null) {
159+
if (other.attributes != null) {
160+
return false;
161+
}
162+
} else if (!attributes.equals(other.attributes)) {
163+
return false;
164+
}
165+
if (userExtSource == null) {
166+
if (other.userExtSource != null) {
167+
return false;
168+
}
169+
} else if (!userExtSource.equals(other.userExtSource)) {
170+
return false;
171+
}
172+
return true;
173+
}
174+
135175
}

0 commit comments

Comments
 (0)