From 90a6ab6c63699343acf3adcd4346bce2f5665bdd Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 07 Jul 2015 15:12:28 +0000
Subject: [PATCH] AutoRefactor'ed Use Diamond Operator

---
 opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java |   63 +++++++------------------------
 1 files changed, 15 insertions(+), 48 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java
index 1891782..a2d586d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java
@@ -118,7 +118,7 @@
     this.requiresAdminAction = requiresAdminAction;
 
     hasPendingValues = false;
-    activeValues     = new LinkedHashSet<ByteString>();
+    activeValues     = new LinkedHashSet<>();
     pendingValues    = activeValues;
   }
 
@@ -152,15 +152,7 @@
     this.requiresAdminAction = requiresAdminAction;
     this.hasPendingValues    = false;
 
-    if (activeValues == null)
-    {
-      this.activeValues = new LinkedHashSet<ByteString>();
-    }
-    else
-    {
-      this.activeValues = activeValues;
-    }
-
+    this.activeValues = notNull(activeValues);
     this.pendingValues = this.activeValues;
   }
 
@@ -204,29 +196,15 @@
     this.requiresAdminAction = requiresAdminAction;
     this.hasPendingValues    = hasPendingValues;
 
-    if (activeValues == null)
-    {
-      this.activeValues = new LinkedHashSet<ByteString>();
-    }
-    else
-    {
-      this.activeValues = activeValues;
-    }
+    this.activeValues = notNull(activeValues);
 
-    if (! hasPendingValues)
+    if (!hasPendingValues)
     {
       this.pendingValues = this.activeValues;
     }
     else
     {
-      if (pendingValues == null)
-      {
-        this.pendingValues = new LinkedHashSet<ByteString>();
-      }
-      else
-      {
-        this.pendingValues = pendingValues;
-      }
+      this.pendingValues = notNull(pendingValues);
     }
   }
 
@@ -418,27 +396,13 @@
       {
         if (requiresAdminAction)
         {
-          if (values == null)
-          {
-            pendingValues = new LinkedHashSet<ByteString>();
-          }
-          else
-          {
-            pendingValues = values;
-          }
+          pendingValues = notNull(values);
 
           hasPendingValues = true;
         }
         else
         {
-          if (values == null)
-          {
-            activeValues = new LinkedHashSet<ByteString>();
-          }
-          else
-          {
-            activeValues = values;
-          }
+          activeValues = notNull(values);
 
           pendingValues    = activeValues;
           hasPendingValues = false;
@@ -498,7 +462,10 @@
     }
   }
 
-
+  private LinkedHashSet<ByteString> notNull(LinkedHashSet<ByteString> values)
+  {
+    return values != null ? values : new LinkedHashSet<ByteString>();
+  }
 
   /**
    * Specifies the set of active values for this configuration attribute.  No
@@ -572,7 +539,7 @@
     // Create a temporary set of values that we will use for this change.  It
     // may not actually be applied if an error occurs for some reason.
     final LinkedHashSet<ByteString> vals = getValues();
-    LinkedHashSet<ByteString> tempValues = new LinkedHashSet<ByteString>(vals.size() + numValues);
+    LinkedHashSet<ByteString> tempValues = new LinkedHashSet<>(vals.size() + numValues);
 
     // Iterate through all of the provided values.  Make sure that each is
     // acceptable for use and that it is not already contained in the value set.
@@ -629,7 +596,7 @@
   {
     // Create a temporary set of values that we will use for this change.  It
     // may not actually be applied if an error occurs for some reason.
-    LinkedHashSet<ByteString> tempValues = new LinkedHashSet<ByteString>(getValues());
+    LinkedHashSet<ByteString> tempValues = new LinkedHashSet<>(getValues());
 
     // Iterate through all the provided values and make sure that they are
     // contained in the list.  If not, then throw an exception.  If so, then
@@ -689,7 +656,7 @@
     {
       if (pendingValues == null)
       {
-        pendingValues = new LinkedHashSet<ByteString>();
+        pendingValues = new LinkedHashSet<>();
       }
       else
       {
@@ -722,7 +689,7 @@
   {
     if (values == null)
     {
-      values = new LinkedHashSet<ByteString>();
+      values = new LinkedHashSet<>();
     }
 
     activeValues     = values;

--
Gitblit v1.10.0