jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1429362 - /jmeter/trunk/src/jorphan/org/apache/jorphan/collections/HashTree.java
Date Sat, 05 Jan 2013 19:24:30 GMT
Author: pmouawad
Date: Sat Jan  5 19:24:29 2013
New Revision: 1429362

URL: http://svn.apache.org/viewvc?rev=1429362&view=rev
Log:
Factor out constructor

Modified:
    jmeter/trunk/src/jorphan/org/apache/jorphan/collections/HashTree.java

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/collections/HashTree.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/collections/HashTree.java?rev=1429362&r1=1429361&r2=1429362&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/collections/HashTree.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/collections/HashTree.java Sat Jan  5 19:24:29
2013
@@ -63,14 +63,14 @@ public class HashTree implements Seriali
      * Creates an empty new HashTree.
      */
     public HashTree() {
-        data = new HashMap<Object, HashTree>();
+        this(null, null);
     }
 
     /**
      * Allow subclasses to provide their own Map.
      */
     protected HashTree(Map<Object, HashTree> _map) {
-        data = _map;
+        this(_map, null);
     }
 
     /**
@@ -79,8 +79,23 @@ public class HashTree implements Seriali
      * @param key
      */
     public HashTree(Object key) {
-        data = new HashMap<Object, HashTree>();
-        data.put(key, new HashTree());
+        this(new HashMap<Object, HashTree>(), key);
+    }
+    
+    /**
+     * Uses the new HashTree if not null and adds the given object as a top-level node if
not null
+     * @param _map
+     * @param key
+     */
+    public HashTree(Map<Object, HashTree> _map, Object key) {
+        if(_map != null) {
+            data = _map;
+        } else {
+            data = new HashMap<Object, HashTree>();
+        }
+        if(key != null) {
+            data.put(key, new HashTree());
+        }
     }
 
     /**



Mime
View raw message