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

Jean-Noël Rouvignac
07.24.2016 18dc6866af53fb06efb0879f9c9c369e698d7379
opendj-server-legacy/src/main/java/org/opends/admin/ads/util/PreferredConnection.java
@@ -12,11 +12,11 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2008-2009 Sun Microsystems, Inc.
 * Portions Copyright 2013-2015 ForgeRock AS.
 * Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.admin.ads.util;
import java.util.LinkedHashSet;
import java.util.Collections;
import java.util.Set;
import javax.naming.ldap.InitialLdapContext;
@@ -71,13 +71,13 @@
    return type;
  }
  /** {@inheritDoc} */
  @Override
  public int hashCode()
  {
    return (type+ldapUrl.toLowerCase()).hashCode();
  }
  /** {@inheritDoc} */
  @Override
  public boolean equals(Object o)
  {
    if (this == o)
@@ -93,15 +93,13 @@
    return false;
  }
  /**
   * Commodity method that returns a PreferredConnection object with the
   * information on a given InitialLdapContext.
   * @param ctx the connection we retrieve the information from.
   * @return a preferred connection object.
   */
  public static PreferredConnection getPreferredConnection(
      InitialLdapContext ctx)
  public static PreferredConnection getPreferredConnection(InitialLdapContext ctx)
  {
    String ldapUrl = ConnectionUtils.getLdapUrl(ctx);
    PreferredConnection.Type type;
@@ -120,20 +118,14 @@
    return new PreferredConnection(ldapUrl, type);
  }
  /**
   * Commodity method that generates a list of preferred connection (of just
   * one) with the information on a given InitialLdapContext.
   * @param ctx the connection we retrieve the information from.
   * @return a list containing the preferred connection object.
   */
  public static Set<PreferredConnection> getPreferredConnections(
      InitialLdapContext ctx)
  public static Set<PreferredConnection> getPreferredConnections(InitialLdapContext ctx)
  {
    PreferredConnection cnx = PreferredConnection.getPreferredConnection(ctx);
    Set<PreferredConnection> returnValue = new LinkedHashSet<>();
    returnValue.add(cnx);
    return returnValue;
    return Collections.singleton(getPreferredConnection(ctx));
  }
}