From 3849edbb8f64ee7febecb261cd0c08fbb6a1916f Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 11 May 2007 12:24:25 +0000
Subject: [PATCH] Add isChildOf and isParentOf methods for determining the inheritance relationship between two managed object definitions. Also make the property definition and relation definitin registration methods protected.

---
 opendj-sdk/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java |   50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java b/opendj-sdk/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
index b1853a6..bdb6108 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
@@ -521,6 +521,52 @@
 
 
   /**
+   * Determines whether or not this managed object definition is a
+   * sub-type of the provided managed object definition. This managed
+   * object definition is a sub-type of the provided managed object
+   * definition if they are both the same or if the provided managed
+   * object definition can be obtained by recursive invocations of the
+   * {@link #getParent()} method.
+   *
+   * @param d
+   *          The managed object definition to be checked.
+   * @return Returns <code>true</code> if this managed object
+   *         definition is a sub-type of the provided managed object
+   *         definition.
+   */
+  public final boolean isChildOf(AbstractManagedObjectDefinition<?, ?> d) {
+    AbstractManagedObjectDefinition<?, ?> i;
+    for (i = this; i != null; i = i.parent) {
+      if (i == d) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+
+
+  /**
+   * Determines whether or not this managed object definition is a
+   * super-type of the provided managed object definition. This
+   * managed object definition is a super-type of the provided managed
+   * object definition if they are both the same or if the provided
+   * managed object definition is a member of the set of children
+   * returned from {@link #getAllChildren()}.
+   *
+   * @param d
+   *          The managed object definition to be checked.
+   * @return Returns <code>true</code> if this managed object
+   *         definition is a super-type of the provided managed object
+   *         definition.
+   */
+  public final boolean isParentOf(AbstractManagedObjectDefinition<?, ?> d) {
+    return d.isChildOf(this);
+  }
+
+
+
+  /**
    * Register a property definition with the managed object definition,
    * overriding any existing property definition with the same name.
    * <p>
@@ -529,7 +575,7 @@
    * @param d
    *          The property definition to be registered.
    */
-  public final void registerPropertyDefinition(PropertyDefinition d) {
+  protected final void registerPropertyDefinition(PropertyDefinition d) {
     String name = d.getName();
 
     propertyDefinitions.put(name, d);
@@ -546,7 +592,7 @@
    * @param d
    *          The relation definition to be registered.
    */
-  public final void registerRelationDefinition(RelationDefinition d) {
+  protected final void registerRelationDefinition(RelationDefinition d) {
     String name = d.getName();
 
     relationDefinitions.put(name, d);

--
Gitblit v1.10.0