mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
19.09.2016 b9e895852290799d8bdaa3ff81e4d47709bf2326
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;
  }
}