From c49cdeba466abea9cebd03b2b2d73e20644d25d0 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Thu, 28 May 2015 09:21:56 +0000
Subject: [PATCH] OPENDJ-2044 Code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SuffixesToReplicateOptions.java |   87 ++++++++++---------------------------------
 1 files changed, 20 insertions(+), 67 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SuffixesToReplicateOptions.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SuffixesToReplicateOptions.java
index bfce0d1..a4984b7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SuffixesToReplicateOptions.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SuffixesToReplicateOptions.java
@@ -24,8 +24,6 @@
  *      Copyright 2006-2010 Sun Microsystems, Inc.
  *      Portions Copyright 2015 ForgeRock AS
  */
-
-
 package org.opends.quicksetup.installer;
 
 import java.util.LinkedHashSet;
@@ -36,28 +34,22 @@
 /**
  * This class is used to provide a data model for the Suffix to Replicate
  * Options panel of the installer.
- *
  */
 public class SuffixesToReplicateOptions
 {
   /**
    * This enumeration is used to know what the user wants to do for the data
    * (import data or not, what use as source of the data...).
-   *
    */
   public enum Type
   {
-    /**
-     * Do not replicate suffix.
-     */
+    /** Do not replicate suffix. */
     NO_SUFFIX_TO_REPLICATE,
-    /**
-     * This is a new suffix in topology..
-     */
+
+    /** This is a new suffix in topology.. */
     NEW_SUFFIX_IN_TOPOLOGY,
-    /**
-     * Replicate Contents of the new Suffix with existings server.
-     */
+
+    /** Replicate Contents of the new Suffix with existings server. */
     REPLICATE_WITH_EXISTING_SUFFIXES
   }
 
@@ -68,55 +60,19 @@
   /**
    * Constructor for the SuffixesToReplicateOptions object.
    *
-   * If the Data Replicate Options is NO_SUFFIX_TO_REPLICATE or
-   * NEW_SUFFIX_IN_TOPOLOGY no args are considered.
-   *
-   * If the Data Options is REPLICATE_WITH_EXISTING_SUFFIXES a Set of
-   * SuffixDescriptor is passed as argument.
-   *
-   * @param type the Type of DataReplicationOptions.
-   * @param args the different argument objects (depending on the Type
-   * specified)
+   * @param type
+   *          the Type of DataReplicationOptions.
+   * @param availableSuffixes
+   *          The set of suffixes which are available for replication.
+   * @param suffixesToReplicate
+   *          The set of suffixes which user wants to replicate.
    */
-  public SuffixesToReplicateOptions(Type type, Object... args)
+  public SuffixesToReplicateOptions(Type type, Set<SuffixDescriptor> availableSuffixes,
+      Set<SuffixDescriptor> suffixesToReplicate)
   {
     this.type = type;
-
-    switch (type)
-    {
-    case REPLICATE_WITH_EXISTING_SUFFIXES:
-      Set<?> s = (Set<?>)args[0];
-      availableSuffixes = new LinkedHashSet<SuffixDescriptor>();
-      for (Object o: s)
-      {
-        availableSuffixes.add((SuffixDescriptor)o);
-      }
-      s = (Set<?>)args[1];
-      suffixesToReplicate = new LinkedHashSet<SuffixDescriptor>();
-      for (Object o: s)
-      {
-        suffixesToReplicate.add((SuffixDescriptor)o);
-      }
-      break;
-
-    default:
-      // If there is something put it.
-      if ((args != null) && (args.length > 0))
-      {
-        s = (Set<?>)args[0];
-        availableSuffixes = new LinkedHashSet<SuffixDescriptor>();
-        for (Object o: s)
-        {
-          availableSuffixes.add((SuffixDescriptor)o);
-        }
-        s = (Set<?>)args[1];
-        suffixesToReplicate = new LinkedHashSet<SuffixDescriptor>();
-        for (Object o: s)
-        {
-          suffixesToReplicate.add((SuffixDescriptor)o);
-        }
-      }
-    }
+    this.availableSuffixes = new LinkedHashSet<>(availableSuffixes);
+    this.suffixesToReplicate = new LinkedHashSet<>(suffixesToReplicate);
   }
 
   /**
@@ -131,25 +87,22 @@
   }
 
   /**
-   * Returns the set of suffixes that we must replicate with.
-   * If there are no suffixes to replicate with returns null.
+   * Returns the set of suffixes available for replication.
    *
-   * @return the set of suffixes that we must replicate with.
+   * @return the set of suffixes available for replication.
    */
   public Set<SuffixDescriptor> getAvailableSuffixes()
   {
-    return new LinkedHashSet<SuffixDescriptor>(availableSuffixes);
+    return availableSuffixes;
   }
 
   /**
-   * Returns the set of suffixes that we must replicate with.
-   * If there are no suffixes to replicate with returns null.
+   * The set of suffixes that we must replicate with.
    *
    * @return the set of suffixes that we must replicate with.
    */
   public Set<SuffixDescriptor> getSuffixes()
   {
-    return new LinkedHashSet<SuffixDescriptor>(suffixesToReplicate);
+    return suffixesToReplicate;
   }
 }
-

--
Gitblit v1.10.0