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/ObjectClass.java | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClass.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClass.java
index 7bf6a1b..ae4f1d4 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClass.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClass.java
@@ -136,18 +136,25 @@
this.definition = buildDefinition();
}
+ /**
+ * Returns {@code true} if the provided object is an object class having the
+ * same numeric OID as this object class.
+ *
+ * @param o
+ * The object to be compared.
+ * @return {@code true} if the provided object is a object class having the
+ * same numeric OID as this object class.
+ */
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
- }
-
- if (o instanceof ObjectClass) {
+ } else if (o instanceof ObjectClass) {
final ObjectClass other = (ObjectClass) o;
return oid.equals(other.oid);
+ } else {
+ return false;
}
-
- return false;
}
/**
@@ -252,6 +259,12 @@
return superiorClasses;
}
+ /**
+ * Returns the hash code for this object class. It will be calculated as the
+ * hash code of the numeric OID.
+ *
+ * @return The hash code for this object class.
+ */
@Override
public int hashCode() {
return oid.hashCode();
--
Gitblit v1.10.0