Skip to content

Commit

Permalink
Implement equals and hashCode for Identity
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillar committed Jul 31, 2024
1 parent 59f840c commit 9125f1c
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.dcache.gplazma.alise;

import com.google.common.base.Objects;
import java.net.URI;
import static java.util.Objects.requireNonNull;

Expand All @@ -40,4 +41,23 @@ public String sub() {
public URI issuer() {
return issuer;
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

if (!(other instanceof Identity)) {
return false;
}

Identity otherIdentity = (Identity)other;
return otherIdentity.sub.equals(sub) && otherIdentity.issuer.equals(issuer);
}

@Override
public int hashCode() {
return Objects.hashCode(sub, issuer);
}
}

0 comments on commit 9125f1c

Please sign in to comment.