From 9125f1ca1389bae0e8894d41d58935346ed321f9 Mon Sep 17 00:00:00 2001 From: Paul Millar Date: Wed, 31 Jul 2024 23:39:27 +0200 Subject: [PATCH] Implement equals and hashCode for Identity --- .../org/dcache/gplazma/alise/Identity.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/gplazma2-alise/src/main/java/org/dcache/gplazma/alise/Identity.java b/modules/gplazma2-alise/src/main/java/org/dcache/gplazma/alise/Identity.java index 8e74064974c..54e82509b7f 100644 --- a/modules/gplazma2-alise/src/main/java/org/dcache/gplazma/alise/Identity.java +++ b/modules/gplazma2-alise/src/main/java/org/dcache/gplazma/alise/Identity.java @@ -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; @@ -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); + } }