From c17e2c6f9b9921e93282ba3727d94b51f92ea39c Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 03 Jul 2013 14:03:48 +0000
Subject: [PATCH] AttrHistoricalMultiple.java: Added javadocs explaining the use of collection classes. Increased encapsulation a bit.

---
 opends/src/server/org/opends/server/replication/plugin/AttrHistoricalMultiple.java |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/AttrHistoricalMultiple.java b/opends/src/server/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
index a48125b..39a3439 100644
--- a/opends/src/server/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
+++ b/opends/src/server/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
@@ -55,7 +55,18 @@
   private ChangeNumber deleteTime;
   /** Last time the attribute was modified. */
   private ChangeNumber lastUpdateTime;
-  private final Map<AttrValueHistorical,AttrValueHistorical> valuesHist;
+  /**
+   * Change history for the values of this attribute. We are using a
+   * LinkedHasMap here because we want:
+   * <ol>
+   * <li>Fast access for removing/adding a AttrValueHistorical keyed by the
+   * AttributeValue => Use a Map</li>
+   * <li>Ordering changes according to the changeNumber of each changes => Use a
+   * LinkedHashMap</li>
+   * </ol>
+   */
+  private final Map<AttrValueHistorical, AttrValueHistorical> valuesHist =
+      new LinkedHashMap<AttrValueHistorical, AttrValueHistorical>();
 
    /**
     * Create a new object from the provided informations.
@@ -69,11 +80,10 @@
    {
      this.deleteTime = deleteTime;
      this.lastUpdateTime = updateTime;
-     if (valuesHist == null)
-       this.valuesHist =
-         new LinkedHashMap<AttrValueHistorical,AttrValueHistorical>();
-     else
-       this.valuesHist = valuesHist;
+     if (valuesHist != null)
+     {
+       this.valuesHist.putAll(valuesHist);
+     }
    }
 
    /**
@@ -83,8 +93,6 @@
    {
      this.deleteTime = null;
      this.lastUpdateTime = null;
-     this.valuesHist =
-         new LinkedHashMap<AttrValueHistorical,AttrValueHistorical>();
    }
 
    /**
@@ -428,7 +436,7 @@
       Iterator<AttrValueHistorical> it = valuesHist.keySet().iterator();
       while (it.hasNext())
       {
-        AttrValueHistorical valInfo; valInfo = it.next();
+        AttrValueHistorical valInfo = it.next();
 
         if (changeNumber.older(valInfo.getValueUpdateTime()))
         {
@@ -596,7 +604,7 @@
           builder.remove(addVal);
         }
         else
-        {
+        { // it is a delete
           /* this value is marked as a deleted value
            * check if this mod is more recent the this delete
            */

--
Gitblit v1.10.0