From 9898c1656694000aa090269e7b9889894cf2f063 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 07 May 2012 10:20:21 +0000
Subject: [PATCH] Fix OPENDJ-484: Implement equals and hashCode for SDK schema elements
---
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java
index 103e013..9e3eee1 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java
@@ -90,6 +90,27 @@
}
/**
+ * Returns {@code true} if the provided object is an attribute syntax having
+ * the same numeric OID as this attribute syntax.
+ *
+ * @param o
+ * The object to be compared.
+ * @return {@code true} if the provided object is an attribute syntax having
+ * the same numeric OID as this attribute syntax.
+ */
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (o instanceof Syntax) {
+ final Syntax other = (Syntax) o;
+ return oid.equals(other.oid);
+ } else {
+ return false;
+ }
+ }
+
+ /**
* Retrieves the default approximate matching rule that will be used for
* attributes with this syntax.
*
@@ -147,14 +168,14 @@
}
/**
- * Retrieves the hash code for this schema element. It will be calculated as
- * the sum of the characters in the OID.
+ * Returns the hash code for this attribute syntax. It will be calculated as
+ * the hash code of the numeric OID.
*
* @return The hash code for this attribute syntax.
*/
@Override
public int hashCode() {
- return getOID().hashCode();
+ return oid.hashCode();
}
/**
--
Gitblit v1.10.0