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

Matthew Swift
07.28.2014 0e8d607d49d683199d938e0dba22c79342937991
opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/DNBuilder.java
File was renamed from opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPNameBuilder.java
@@ -20,8 +20,8 @@
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS.
 */
package org.forgerock.opendj.config.client.ldap;
@@ -48,7 +48,7 @@
/**
 * A strategy for creating <code>DN</code>s from managed object paths.
 */
final class LDAPNameBuilder implements ManagedObjectPathSerializer {
final class DNBuilder implements ManagedObjectPathSerializer {
    /**
     * Creates a new DN representing the specified managed object path.
@@ -59,10 +59,10 @@
     *            The LDAP profile which should be used to construct LDAP names.
     * @return Returns a new DN representing the specified managed object path.
     */
    public static DN create(ManagedObjectPath<?, ?> path, LDAPProfile profile) {
        LDAPNameBuilder builder = new LDAPNameBuilder(profile);
    static DN create(ManagedObjectPath<?, ?> path, LDAPProfile profile) {
        DNBuilder builder = new DNBuilder(profile);
        path.serialize(builder);
        return builder.getInstance();
        return builder.build();
    }
    /**
@@ -78,12 +78,12 @@
     * @return Returns a new DN representing the specified managed object path
     *         and instantiable relation.
     */
    public static DN create(ManagedObjectPath<?, ?> path, InstantiableRelationDefinition<?, ?> relation,
            LDAPProfile profile) {
        LDAPNameBuilder builder = new LDAPNameBuilder(profile);
    static DN create(ManagedObjectPath<?, ?> path,
            InstantiableRelationDefinition<?, ?> relation, LDAPProfile profile) {
        DNBuilder builder = new DNBuilder(profile);
        path.serialize(builder);
        builder.appendManagedObjectPathElement(relation);
        return builder.getInstance();
        return builder.build();
    }
    /**
@@ -99,11 +99,12 @@
     * @return Returns a new DN representing the specified managed object path
     *         and set relation.
     */
    public static DN create(ManagedObjectPath<?, ?> path, SetRelationDefinition<?, ?> relation, LDAPProfile profile) {
        LDAPNameBuilder builder = new LDAPNameBuilder(profile);
    static DN create(ManagedObjectPath<?, ?> path, SetRelationDefinition<?, ?> relation,
            LDAPProfile profile) {
        DNBuilder builder = new DNBuilder(profile);
        path.serialize(builder);
        builder.appendManagedObjectPathElement(relation);
        return builder.getInstance();
        return builder.build();
    }
    /** The list of RDNs in big-endian order. */
@@ -117,7 +118,7 @@
     * @param profile
     *            The LDAP profile which should be used to construct DNs.
     */
    public LDAPNameBuilder(LDAPProfile profile) {
    private DNBuilder(LDAPProfile profile) {
        this.rdns = new LinkedList<RDN>();
        this.profile = profile;
    }
@@ -126,8 +127,8 @@
     * {@inheritDoc}
     */
    public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement(
        InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d,
        String name) {
            InstantiableRelationDefinition<? super C, ? super S> r,
            AbstractManagedObjectDefinition<C, S> d, String name) {
        // Add the RDN sequence representing the relation.
        appendManagedObjectPathElement(r);
@@ -144,7 +145,7 @@
     * @param r
     *            The relation definition.
     */
    public void appendManagedObjectPathElement(RelationDefinition<?, ?> r) {
    private void appendManagedObjectPathElement(RelationDefinition<?, ?> r) {
        // Add the RDN sequence representing the relation.
        DN dn = DN.valueOf(profile.getRelationRDNSequence(r));
        List<RDN> rdnsOfDn = getRdnsInBigEndianOrder(dn);
@@ -171,7 +172,8 @@
     * {@inheritDoc}
     */
    public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement(
            OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) {
            OptionalRelationDefinition<? super C, ? super S> r,
            AbstractManagedObjectDefinition<C, S> d) {
        // Add the RDN sequence representing the relation.
        appendManagedObjectPathElement(r);
    }
@@ -180,7 +182,8 @@
     * {@inheritDoc}
     */
    public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement(
            SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) {
            SingletonRelationDefinition<? super C, ? super S> r,
            AbstractManagedObjectDefinition<C, S> d) {
        // Add the RDN sequence representing the relation.
        appendManagedObjectPathElement(r);
    }
@@ -204,7 +207,7 @@
     *
     * @return Returns the new DN instance.
     */
    public DN getInstance() {
    private DN build() {
        DN dn = DN.rootDN();
        for (RDN rdn : rdns) {
            dn = dn.child(rdn);