From 5360b07bd36e6b3479c1bb3f911bb34f8d661b1f Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Wed, 21 Sep 2016 15:15:44 +0000
Subject: [PATCH] OPENDJ-2413 Apply PR comments: remove builders in parameters classes, simplify configuration retrieval Include also other minor changes and renaming

---
 opendj-server-legacy/src/main/java/org/opends/server/util/embedded/ConfigParameters.java |  142 ++++++++++++++++++-----------------------------
 1 files changed, 55 insertions(+), 87 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/embedded/ConfigParameters.java b/opendj-server-legacy/src/main/java/org/opends/server/util/embedded/ConfigParameters.java
index 4bc1d8b..23fc905 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/embedded/ConfigParameters.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/embedded/ConfigParameters.java
@@ -15,11 +15,7 @@
  */
 package org.opends.server.util.embedded;
 
-import org.forgerock.util.Reject;
-
-/**
- * Parameters to configure a directory server.
- */
+/** Parameters to configure a directory server. */
 public final class ConfigParameters
 {
   private String serverRootDirectory;
@@ -29,17 +25,17 @@
 
   private ConfigParameters()
   {
-    // private constructor to force usage of the associated Builder
+    // prefer usage of static method for creation
   }
 
   /**
-   * Creates a builder for the configuration parameters.
+   * Creates configuration parameters.
    *
-   * @return a builder
+   * @return the parameters
    */
-  public static Builder configParams()
+  public static ConfigParameters configParams()
   {
-    return new Builder();
+    return new ConfigParameters();
   }
 
   String getServerRootDirectory()
@@ -47,7 +43,7 @@
     return serverRootDirectory;
   }
 
-  /** This value may be {@code null}, it must always  be checked. */
+  /** This value may be {@code null}, it must always be checked. */
   String getServerInstanceDirectory()
   {
     return serverInstanceDirectory;
@@ -64,86 +60,58 @@
   }
 
   /**
-   * Builder for this class.
+   * Sets the server root directory of the directory server.
+   * <p>
+   * The server root is the location where the binaries and default configuration is stored.
+   *
+   * @param dir
+   *          the server root directory
+   * @return this builder
    */
-  public static final class Builder
+  public ConfigParameters serverRootDirectory(String dir)
   {
-    private ConfigParameters params;
+    serverRootDirectory = dir;
+    return this;
+  }
 
-    private Builder()
-    {
-      params = new ConfigParameters();
-    }
+  /**
+   * Sets the install root directory of the directory server.
+   * <p>
+   * The install root is the location where the data and live configuration is stored.
+   *
+   * @param dir
+   *          the install root directory
+   * @return this builder
+   */
+  public ConfigParameters serverInstanceDirectory(String dir)
+  {
+    serverInstanceDirectory = dir;
+    return this;
+  }
 
-    /**
-     * Generates the parameters from this builder.
-     * <p>
-     * After this call, the builder is reset and can be used to generate other parameters.
-     *
-     * @return the replication parameters
-     */
-    public ConfigParameters toParams()
-    {
-      ConfigParameters p = params;
-      Reject.ifNull(p.serverRootDirectory, p.configurationFile);
-      this.params = new ConfigParameters();
-      return p;
-    }
+  /**
+   * Sets the path of the configuration file of the directory server.
+   *
+   * @param file
+   *          the configuration file
+   * @return this builder
+   */
+  public ConfigParameters configurationFile(String file)
+  {
+    configurationFile = file;
+    return this;
+  }
 
-    /**
-     * Sets the server root directory of the directory server.
-     * <p>
-     * The server root is the location where the binaries and default configuration is stored.
-     *
-     * @param dir
-     *          the server root directory
-     * @return this builder
-     */
-    public Builder serverRootDirectory(String dir)
-    {
-      params.serverRootDirectory = dir;
-      return this;
-    }
-
-    /**
-     * Sets the install root directory of the directory server.
-     * <p>
-     * The install root is the location where the data and live configuration is stored.
-     *
-     * @param dir
-     *          the install root directory
-     * @return this builder
-     */
-    public Builder serverInstanceDirectory(String dir)
-    {
-      params.serverInstanceDirectory = dir;
-      return this;
-    }
-
-    /**
-     * Sets the path of the configuration file of the directory server.
-     *
-     * @param file
-     *          the configuration file
-     * @return this builder
-     */
-    public Builder configurationFile(String file)
-    {
-      params.configurationFile = file;
-      return this;
-    }
-
-    /**
-     * Sets the indicator allowing to disable the connection handlers.
-     *
-     * @param disable
-     *          {@code true} to disable the connection handlers
-     * @return this builder
-     */
-    public Builder disableConnectionHandlers(boolean disable)
-    {
-      params.disableConnectionHandlers = disable;
-      return this;
-    }
+  /**
+   * Sets the indicator allowing to disable the connection handlers.
+   *
+   * @param disable
+   *          {@code true} to disable the connection handlers
+   * @return this builder
+   */
+  public ConfigParameters disableConnectionHandlers(boolean disable)
+  {
+    disableConnectionHandlers = disable;
+    return this;
   }
 }
\ No newline at end of file

--
Gitblit v1.10.0