feat: implement identifier-based equals/hashCode for PromptReference (#514)

Ensure PromptReference equality is based solely on identifier and type fields, ignoring other fields like title

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
Christian Tzolov 2025-08-25 12:46:59 +02:00 • committed by GitHub
commit 888e555026
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2351,6 +2351,22 @@ public final class McpSchema {
public String identifier() {
return name();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || getClass() != obj.getClass())
return false;
PromptReference that = (PromptReference) obj;
return java.util.Objects.equals(identifier(), that.identifier())
&& java.util.Objects.equals(type(), that.type());
}
@Override
public int hashCode() {
return java.util.Objects.hash(identifier(), type());
}
}
/**