From b9e895852290799d8bdaa3ff81e4d47709bf2326 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 30 May 2016 10:43:09 +0000
Subject: [PATCH] OPENDJ-2987 Adapt SomeSchemaElement and SchemaUtils

---
 opendj-server-legacy/src/main/java/org/opends/server/util/SchemaUtils.java |   45 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/SchemaUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/util/SchemaUtils.java
index 7a7dea9..d0fa47d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/SchemaUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/SchemaUtils.java
@@ -15,11 +15,16 @@
  */
 package org.opends.server.util;
 
-import org.forgerock.opendj.ldap.schema.AttributeType;
-
 import static org.opends.server.schema.SchemaConstants.SYNTAX_AUTH_PASSWORD_OID;
 import static org.opends.server.schema.SchemaConstants.SYNTAX_USER_PASSWORD_OID;
 
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.ObjectClass;
+
 /** Utility methods related to schema. */
 public class SchemaUtils
 {
@@ -60,4 +65,40 @@
     }
     return PasswordType.NOT_A_PASSWORD;
   }
+
+  /**
+   * Returns a new collection with the result of calling {@link ObjectClass#getNameOrOID()} on each
+   * element of the provided collection.
+   *
+   * @param objectClasses
+   *          the schema elements on which to act
+   * @return a new collection comprised of the names or OIDs of each element
+   */
+  public static Collection<String> getNameOrOIDsForOCs(Collection<ObjectClass> objectClasses)
+  {
+    Set<String> results = new HashSet<>(objectClasses.size());
+    for (ObjectClass objectClass : objectClasses)
+    {
+      results.add(objectClass.getNameOrOID());
+    }
+    return results;
+  }
+
+  /**
+   * Returns a new collection with the result of calling {@link AttributeType#getNameOrOID()} on
+   * each element of the provided collection.
+   *
+   * @param attributeTypes
+   *          the schema elements on which to act
+   * @return a new collection comprised of the names or OIDs of each element
+   */
+  public static Collection<String> getNameOrOIDsForATs(Collection<AttributeType> attributeTypes)
+  {
+    Set<String> results = new HashSet<>(attributeTypes.size());
+    for (AttributeType attrType : attributeTypes)
+    {
+      results.add(attrType.getNameOrOID());
+    }
+    return results;
+  }
 }

--
Gitblit v1.10.0