BUG-7464: Reformat source code 64/49864/7
authorRobert Varga <rovarga@cisco.com>
Fri, 30 Dec 2016 10:18:13 +0000 (11:18 +0100)
committerRobert Varga <rovarga@cisco.com>
Mon, 9 Jan 2017 14:17:12 +0000 (15:17 +0100)
This is an automatic reformat, performing the following:
- remove trailing whitespace
- organize imports
- make arguments final
- add explicit braces
- use diamond for instantiation

Change-Id: I08f578bf40b72c0a592f3adf5add4a275c376f3d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
26 files changed:
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/BasicNode.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNodeBase.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/INodeBase.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ListMap.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/MainNode.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/None.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Option.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Some.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeFlagCollision.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeInsertionIncorrectOrder.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapPutIfAbsent.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapRemove.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapReplace.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestDelete.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisions.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemove.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemoveIterator.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHelper.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInsert.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMapIterator.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadAddDelete.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadInserts.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadMapIterator.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestReadOnlyAndUpdatableIterators.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestSerialization.java

index 82b99193cd236b4d312cfd05e98700ac43ecd6c8..d733abd4843c2705eb3186f7ff1037dc76c45a79 100644 (file)
@@ -14,7 +14,7 @@ package org.opendaylight.yangtools.triemap;
 
 
 abstract class BasicNode {
-    
+
     public abstract String string(int lev);
-    
+
 }
\ No newline at end of file
index 2a12749b4db12b05dd67bd607723f82fa903cddd..393df2e658f574ac340c4a37b122faf737bfb68b 100644 (file)
@@ -15,21 +15,21 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 
 
 abstract class CNodeBase<K, V> extends MainNode<K, V> {
-    
+
     public static final AtomicIntegerFieldUpdater<CNodeBase> updater = AtomicIntegerFieldUpdater.newUpdater(CNodeBase.class, "csize");
-    
+
     public volatile int csize = -1;
-    
-    public boolean CAS_SIZE(int oldval, int nval) {
+
+    public boolean CAS_SIZE(final int oldval, final int nval) {
     return updater.compareAndSet(this, oldval, nval);
     }
-    
-    public void WRITE_SIZE(int nval) {
+
+    public void WRITE_SIZE(final int nval) {
     updater.set(this, nval);
     }
-    
+
     public int READ_SIZE() {
     return updater.get(this);
     }
-    
+
 }
\ No newline at end of file
index f09dc838d7cd4cb9d2df273b9bb5318b51da4d26..75a36a8159eceef911f4b3a47c61343c7440ee63 100644 (file)
@@ -15,21 +15,21 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 
 
 abstract class INodeBase<K, V> extends BasicNode {
-    
+
     public static final AtomicReferenceFieldUpdater<INodeBase, MainNode> updater = AtomicReferenceFieldUpdater.newUpdater(INodeBase.class, MainNode.class, "mainnode");
-    
+
     public static final Object RESTART = new Object();
-    
+
     public volatile MainNode<K, V> mainnode = null;
-    
+
     public final Gen gen;
-    
-    public INodeBase(Gen generation) {
+
+    public INodeBase(final Gen generation) {
     gen = generation;
     }
-    
+
     public BasicNode prev() {
     return null;
     }
-    
+
 }
\ No newline at end of file
index 21d7b8469258d57ecee7513a69a266ded0378016..5bab9b15ae83af6a16d0d060c49f7b8fd0c76b8e 100644 (file)
@@ -1,13 +1,13 @@
 package org.opendaylight.yangtools.triemap;
 
-import java.util.Iterator;
 import java.util.AbstractMap.SimpleImmutableEntry;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
 
 /**
  * Mimic immutable ListMap in Scala
- *  
+ *
  * @author Roman Levenstein <romixlev@gmail.com>
  *
  * @param <V>
@@ -15,23 +15,23 @@ import java.util.Map.Entry;
 abstract class ListMap<K,V> {
 
     ListMap<K,V> next;
-    
-    static <K,V> ListMap<K, V> map(K k, V v, ListMap<K, V> tail){
-        return new Node<K, V> (k, v, tail);
+
+    static <K,V> ListMap<K, V> map(final K k, final V v, final ListMap<K, V> tail){
+        return new Node<> (k, v, tail);
     }
 
-    static <K,V> ListMap<K, V> map(K k, V v){
-        return new Node<K, V> (k, v, null);
+    static <K,V> ListMap<K, V> map(final K k, final V v){
+        return new Node<> (k, v, null);
     }
 
-    static <K,V> ListMap<K, V> map(K k1, V v1, K k2, V v2){
-        return new Node<K, V> (k1, v1, new Node<K,V>(k2,v2, null));
+    static <K,V> ListMap<K, V> map(final K k1, final V v1, final K k2, final V v2){
+        return new Node<> (k1, v1, new Node<>(k2,v2, null));
     }
-    
+
     public abstract int size ();
 
     public abstract boolean isEmpty() ;
-    
+
     abstract public boolean contains(K k, V v);
 
     abstract public boolean contains(K key);
@@ -41,24 +41,28 @@ abstract class ListMap<K,V> {
     abstract public ListMap<K, V> add (K key, V value);
 
     abstract public ListMap<K, V> remove (K key);
-    
+
     abstract public Iterator<Map.Entry<K, V>> iterator();
 
-    
+
     static class EmptyListMap<K,V> extends ListMap<K, V> {
-        public ListMap<K,V> add (K key, V value) {
+        @Override
+        public ListMap<K,V> add (final K key, final V value) {
             return ListMap.map(key, value, null);
         }
-        
-        public boolean contains(K k, V v) {
+
+        @Override
+        public boolean contains(final K k, final V v) {
             return false;
         }
-        
-        public boolean contains(K k) {
+
+        @Override
+        public boolean contains(final K k) {
             return false;
         }
-        
-        public ListMap<K,V> remove(K key) {
+
+        @Override
+        public ListMap<K,V> remove(final K key) {
             return this;
         }
 
@@ -73,15 +77,15 @@ abstract class ListMap<K,V> {
         }
 
         @Override
-        public Option<V> get (K key) {
+        public Option<V> get (final K key) {
             return Option.makeOption (null);
         }
 
         @Override
         public Iterator<Entry<K, V>> iterator () {
-            return new EmptyListMapIterator<K, V> ();
-        } 
-        
+            return new EmptyListMapIterator<> ();
+        }
+
         static class EmptyListMapIterator<K,V> implements Iterator<Entry<K, V>> {
 
             @Override
@@ -98,48 +102,55 @@ abstract class ListMap<K,V> {
             public void remove () {
                 throw new RuntimeException("Operation not supported");
             }
-            
+
         }
     }
-    
+
     static class Node<K,V> extends ListMap<K, V> {
         final K k;
         final V v;
-        
-        Node(K k, V v, ListMap<K,V> next) {
+
+        Node(final K k, final V v, final ListMap<K,V> next) {
             this.k = k;
             this.v = v;
             this.next = next;
         }
-        
-        public ListMap<K,V> add (K key, V value) {
+
+        @Override
+        public ListMap<K,V> add (final K key, final V value) {
             return ListMap.map(key, value, remove (key));
         }
-                
-        public boolean contains(K k, V v) {
-            if(k.equals (this.k) && v.equals (this.v))
+
+        @Override
+        public boolean contains(final K k, final V v) {
+            if(k.equals (this.k) && v.equals (this.v)) {
                 return true;
-            else if(next != null) 
+            } else if(next != null) {
                 return next.contains (k, v);
+            }
             return false;
         }
-        
-        public boolean contains(K k) {
-            if(k.equals (this.k))
+
+        @Override
+        public boolean contains(final K k) {
+            if(k.equals (this.k)) {
                 return true;
-            else if(next != null) 
+            } else if(next != null) {
                 return next.contains (k);
+            }
             return false;
         }
-        
-        public ListMap<K,V> remove(K key) {
-            if(!contains(key))
+
+        @Override
+        public ListMap<K,V> remove(final K key) {
+            if(!contains(key)) {
                 return this;
-            else
+            } else {
                 return remove0(key);
+            }
         }
-        
-        private ListMap<K, V> remove0 (K key) {
+
+        private ListMap<K, V> remove0 (final K key) {
             ListMap<K, V> n = this;
             ListMap<K, V> newN = null;
             ListMap<K, V> lastN = null;
@@ -168,10 +179,11 @@ abstract class ListMap<K,V> {
 
         @Override
         public int size () {
-            if(next == null)
+            if(next == null) {
                 return 1;
-            else
+            } else {
                 return 1+next.size ();
+            }
         }
 
         @Override
@@ -180,24 +192,26 @@ abstract class ListMap<K,V> {
         }
 
         @Override
-        public Option<V> get (K key) {
-            if(key.equals (k))
+        public Option<V> get (final K key) {
+            if(key.equals (k)) {
                 return Option.makeOption (v);
-            if(next != null)
+            }
+            if(next != null) {
                 return next.get (key);
+            }
             return Option.makeOption (null);
         }
 
 
         @Override
         public Iterator<Entry<K, V>> iterator () {
-            return new NodeIterator<K, V> (this);
+            return new NodeIterator<> (this);
         }
 
         static class NodeIterator<K,V> implements Iterator<Entry<K, V>> {
             ListMap<K, V> n;
 
-            public NodeIterator (Node<K, V> n) {
+            public NodeIterator (final Node<K, V> n) {
                 this.n = n;
             }
 
@@ -211,7 +225,7 @@ abstract class ListMap<K,V> {
             public Entry<K, V> next () {
                 if (n instanceof Node) {
                     Node<K, V> nn = (Node<K, V>) n;
-                    Entry<K, V> res = new SimpleImmutableEntry<K, V> (nn.k, nn.v);
+                    Entry<K, V> res = new SimpleImmutableEntry<> (nn.k, nn.v);
                     n = n.next;
                     return res;
                 } else {
@@ -223,7 +237,7 @@ abstract class ListMap<K,V> {
             public void remove () {
                 throw new RuntimeException("Operation not supported");
             }
-            
+
         }
     }
 }
index 9ee09a04ad36f65426bc9a641b3b949f2864f532..f6a6fd25b98a43e6b86fd27ec08154690c060e09 100644 (file)
@@ -18,11 +18,11 @@ abstract class MainNode<K, V> extends BasicNode {
 
     public abstract int cachedSize (Object ct);
 
-    public boolean CAS_PREV (MainNode<K, V> oldval, MainNode<K, V> nval) {
+    public boolean CAS_PREV (final MainNode<K, V> oldval, final MainNode<K, V> nval) {
         return updater.compareAndSet (this, oldval, nval);
     }
 
-    public void WRITE_PREV (MainNode<K, V> nval) {
+    public void WRITE_PREV (final MainNode<K, V> nval) {
         updater.set (this, nval);
     }
 
index 6c1190c5b37d7f0112e17d707bfa7934c8df9fd8..218886e15333c5363d1e8a7e5807b1aae5f4bb44 100644 (file)
@@ -2,7 +2,7 @@ package org.opendaylight.yangtools.triemap;
 
 /**
  * Mimic None in Scala
- *  
+ *
  * @author Roman Levenstein <romixlev@gmail.com>
  *
  * @param <V>
index 431a375fbcc036352da1e0a8ff60d7f3193ed1f7..4cff9140cbc93721cf21995cb59dc2b24b3c2624 100644 (file)
@@ -2,7 +2,7 @@ package org.opendaylight.yangtools.triemap;
 
 /**
  * Mimic Option in Scala
- *  
+ *
  * @author Roman Levenstein <romixlev@gmail.com>
  *
  * @param <V>
@@ -10,15 +10,16 @@ package org.opendaylight.yangtools.triemap;
 @SuppressWarnings({"rawtypes", "unchecked"})
 class Option<V> {
     static None none = new None();
-    public static <V> Option<V> makeOption(V o){
-        if(o!=null)
-            return new Some<V>(o);
-        else
-            return (Option<V>)none;
+    public static <V> Option<V> makeOption(final V o){
+        if(o!=null) {
+            return new Some<>(o);
+        } else {
+            return none;
+        }
     }
 
     public static <V> Option<V> makeOption(){
-        return (Option<V>)none;
+        return none;
     }
     public boolean nonEmpty () {
         return false;
index 114ac650c02bddfb0c2e3d4d2a47cdb06d264364..183dd4db6015640e841babf6a312fe6a78ce47f7 100644 (file)
@@ -2,21 +2,22 @@ package org.opendaylight.yangtools.triemap;
 
 /**
  * Mimic Some in Scala
- *  
+ *
  * @author Roman Levenstein <romixlev@gmail.com>
  *
  * @param <V>
  */
 class Some<V> extends Option<V>{
     final V value;
-    public Some(V v) {
+    public Some(final V v) {
         value = v;
     }
-    
+
     public V get() {
         return value;
     }
-    
+
+    @Override
     public boolean nonEmpty () {
         return value != null;
     }
index 63118d3b8019a3be46844e5fd79137da8042ace7..c682e8638099f215b049f6af7fc50815bf590e73 100644 (file)
@@ -6,11 +6,9 @@ import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.lang.reflect.Field;
 import java.util.AbstractMap;
-import java.util.AbstractMap.SimpleImmutableEntry;
 import java.util.AbstractSet;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -21,7 +19,7 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 
 /***
  * This is a port of Scala's TrieMap class from the Scala Collections library.
- * 
+ *
  * @author Roman Levenstein &lt;romixlev@gmail.com&gt;
  *
  * @param <K>
@@ -51,7 +49,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
      * EntrySet
      */
     private transient final EntrySet entrySet = new EntrySet ();
-    
+
     public static <K,V> TrieMap<K,V> empty () {
         return EMPTY;
     }
@@ -68,16 +66,16 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
 
         static <K,V> INode<K,V> newRootNode () {
             Gen gen = new Gen ();
-            CNode<K, V> cn = new CNode<K, V> (0, new BasicNode[] {}, gen);
-            return new INode<K,V>(cn, gen);
+            CNode<K, V> cn = new CNode<> (0, new BasicNode[] {}, gen);
+            return new INode<>(cn, gen);
         }
 
-        public INode (MainNode<K, V> bn, Gen g) {
+        public INode (final MainNode<K, V> bn, final Gen g) {
             super (g);
             WRITE (bn);
         }
 
-        public INode (Gen g) {
+        public INode (final Gen g) {
             this (null, g);
         }
 
@@ -93,33 +91,35 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             return GCAS_READ (ct);
         }
 
-        final MainNode<K, V> GCAS_READ (TrieMap<K, V> ct) {
+        final MainNode<K, V> GCAS_READ (final TrieMap<K, V> ct) {
             MainNode<K, V> m = /* READ */mainnode;
             MainNode<K, V> prevval = /* READ */m.prev;
-            if (prevval == null)
+            if (prevval == null) {
                 return m;
-            else
+            } else {
                 return GCAS_Complete (m, ct);
+            }
         }
 
         private MainNode<K, V> GCAS_Complete (MainNode<K, V> m, final TrieMap<K, V> ct) {
             while (true) {
-                if (m == null)
+                if (m == null) {
                     return null;
-                else {
+                else {
                     // complete the GCAS
                     MainNode<K, V> prev = /* READ */m.prev;
                     INode<K, V> ctr = ct.readRoot (true);
 
-                    if (prev == null)
+                    if (prev == null) {
                         return m;
+                    }
 
                     if (prev instanceof FailedNode) {
                         // try to commit to previous value
                         FailedNode<K, V> fn = (FailedNode<K, V>) prev;
-                        if (CAS (m, fn.prev))
+                        if (CAS (m, fn.prev)) {
                             return fn.prev;
-                        else {
+                        else {
                             // Tailrec
                             // return GCAS_Complete (/* READ */mainnode, ct);
                             m = /* READ */mainnode;
@@ -140,16 +140,16 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                         // or both
                         if ((ctr.gen == gen) && ct.nonReadOnly ()) {
                             // try to commit
-                            if (m.CAS_PREV (prev, null))
+                            if (m.CAS_PREV (prev, null)) {
                                 return m;
-                            else {
+                            else {
                                 // return GCAS_Complete (m, ct);
                                 // tailrec
                                 continue;
                             }
                         } else {
                             // try to abort
-                            m.CAS_PREV (prev, new FailedNode<K, V> (prev));
+                            m.CAS_PREV (prev, new FailedNode<> (prev));
                             return GCAS_Complete (/* READ */mainnode, ct);
                         }
                     }
@@ -163,8 +163,9 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             if (CAS (old, n)) {
                 GCAS_Complete (n, ct);
                 return /* READ */n.prev == null;
-            } else
+            } else {
                 return false;
+            }
         }
 
         private boolean equal (final K k1, final K k2, final TrieMap<K, V> ct) {
@@ -172,13 +173,13 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         }
 
         private INode<K, V> inode (final MainNode<K, V> cn) {
-            INode<K, V> nin = new INode<K, V> (gen);
+            INode<K, V> nin = new INode<> (gen);
             nin.WRITE (cn);
             return nin;
         }
 
         final INode<K, V> copyToGen (final Gen ngen, final TrieMap<K, V> ct) {
-            INode<K, V> nin = new INode<K, V> (ngen);
+            INode<K, V> nin = new INode<> (ngen);
             MainNode<K, V> main = GCAS_READ (ct);
             nin.WRITE (main);
             return nin;
@@ -186,7 +187,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
 
         /**
          * Inserts a key value pair, overwriting the old pair if the keys match.
-         * 
+         *
          * @return true if successful, false otherwise
          */
         final boolean rec_insert (final K k, final V v, final int hc, final int lev, final INode<K, V> parent, final Gen startgen, final TrieMap<K, V> ct) {
@@ -206,22 +207,23 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                         BasicNode cnAtPos = cn.array [pos];
                         if (cnAtPos instanceof INode) {
                             INode<K, V> in = (INode<K, V>) cnAtPos;
-                            if (startgen == in.gen)
+                            if (startgen == in.gen) {
                                 return in.rec_insert (k, v, hc, lev + 5, this, startgen, ct);
-                            else {
+                            else {
                                 if (GCAS (cn, cn.renewed (startgen, ct), ct)) {
                                     // return rec_insert (k, v, hc, lev, parent,
                                     // startgen, ct);
                                     // tailrec
                                     continue;
-                                } else
+                                } else {
                                     return false;
+                                }
                             }
                         } else if (cnAtPos instanceof SNode) {
                             SNode<K, V> sn = (SNode<K, V>) cnAtPos;
-                            if (sn.hc == hc && equal ((K) sn.k, k, ct))
-                                return GCAS (cn, cn.updatedAt (pos, new SNode<K, V> (k, v, hc), gen), ct);
-                            else {
+                            if (sn.hc == hc && equal (sn.k, k, ct)) {
+                                return GCAS (cn, cn.updatedAt (pos, new SNode<> (k, v, hc), gen), ct);
+                            else {
                                 CNode<K, V> rn = (cn.gen == gen) ? cn : cn.renewed (gen, ct);
                                 MainNode<K, V> nn = rn.updatedAt (pos, inode (CNode.dual (sn, sn.hc, new SNode (k, v, hc), hc, lev + 5, gen)), gen);
                                 return GCAS (cn, nn, ct);
@@ -229,7 +231,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                         }
                     } else {
                         CNode<K, V> rn = (cn.gen == gen) ? cn : cn.renewed (gen, ct);
-                        MainNode<K, V> ncnode = rn.insertedAt (pos, flag, new SNode<K, V> (k, v, hc), gen);
+                        MainNode<K, V> ncnode = rn.insertedAt (pos, flag, new SNode<> (k, v, hc), gen);
                         return GCAS (cn, ncnode, ct);
                     }
                 } else if (m instanceof TNode) {
@@ -247,11 +249,11 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
 
         /**
          * Inserts a new key value pair, given that a specific condition is met.
-         * 
+         *
          * @param cond
          *            null - don't care if the key was there
          *            KEY_ABSENT - key wasn't there
-         *            KEY_PRESENT - key was there 
+         *            KEY_PRESENT - key was there
          *            other value `v` - key must be bound to `v`
          * @return null if unsuccessful, Option[V] otherwise (indicating
          *         previous value bound to the key)
@@ -274,76 +276,89 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                         BasicNode cnAtPos = cn.array [pos];
                         if (cnAtPos instanceof INode) {
                             INode<K, V> in = (INode<K, V>) cnAtPos;
-                            if (startgen == in.gen)
+                            if (startgen == in.gen) {
                                 return in.rec_insertif (k, v, hc, cond, lev + 5, this, startgen, ct);
-                            else {
+                            else {
                                 if (GCAS (cn, cn.renewed (startgen, ct), ct)) {
                                     // return rec_insertif (k, v, hc, cond, lev,
                                     // parent, startgen, ct);
                                     // tailrec
                                     continue;
-                                } else
+                                } else {
                                     return null;
+                                }
                             }
                         } else if (cnAtPos instanceof SNode) {
                             SNode<K, V> sn = (SNode<K, V>) cnAtPos;
                             if (cond == null) {
                                 if (sn.hc == hc && equal (sn.k, k, ct)) {
-                                    if (GCAS (cn, cn.updatedAt (pos, new SNode<K, V> (k, v, hc), gen), ct))
+                                    if (GCAS (cn, cn.updatedAt (pos, new SNode<> (k, v, hc), gen), ct)) {
                                         return Option.makeOption(sn.v);
-                                    else
+                                    } else {
                                         return null;
+                                    }
                                 } else {
                                     CNode<K, V> rn = (cn.gen == gen) ? cn : cn.renewed (gen, ct);
                                     MainNode<K, V> nn = rn.updatedAt (pos, inode (CNode.dual (sn, sn.hc, new SNode (k, v, hc), hc, lev + 5, gen)), gen);
-                                    if (GCAS (cn, nn, ct))
+                                    if (GCAS (cn, nn, ct)) {
                                         return Option.makeOption(); // None;
-                                    else
+                                    } else {
                                         return null;
+                                    }
                                 }
 
                             } else if (cond == INode.KEY_ABSENT) {
-                                if (sn.hc == hc && equal (sn.k, k, ct))
+                                if (sn.hc == hc && equal (sn.k, k, ct)) {
                                     return Option.makeOption(sn.v);
-                                else {
+                                else {
                                     CNode<K, V> rn = (cn.gen == gen) ? cn : cn.renewed (gen, ct);
                                     MainNode<K, V> nn = rn.updatedAt (pos, inode (CNode.dual (sn, sn.hc, new SNode (k, v, hc), hc, lev + 5, gen)), gen);
-                                    if (GCAS (cn, nn, ct))
+                                    if (GCAS (cn, nn, ct)) {
                                         return Option.makeOption (); // None
-                                    else
+                                    } else {
                                         return null;
+                                    }
                                 }
                             } else if (cond == INode.KEY_PRESENT) {
                                 if (sn.hc == hc && equal (sn.k, k, ct)) {
-                                    if (GCAS (cn, cn.updatedAt (pos, new SNode<K, V> (k, v, hc), gen), ct))
+                                    if (GCAS (cn, cn.updatedAt (pos, new SNode<> (k, v, hc), gen), ct)) {
                                         return Option.makeOption (sn.v);
-                                    else
+                                    } else {
                                         return null;
+                                    }
 
-                                } else
+                                }
+                                else {
                                     return Option.makeOption ();// None;
+                                }
                             } else {
                                 if (sn.hc == hc && equal (sn.k, k, ct) && sn.v == cond) {
-                                    if (GCAS (cn, cn.updatedAt (pos, new SNode<K, V> (k, v, hc), gen), ct))
+                                    if (GCAS (cn, cn.updatedAt (pos, new SNode<> (k, v, hc), gen), ct)) {
                                         return Option.makeOption (sn.v);
-                                    else
+                                    } else {
                                         return null;
-                                } else
+                                    }
+                                }
+                                else {
                                     return Option.makeOption (); // None
+                                }
                             }
 
                         }
                     } else if (cond == null || cond == INode.KEY_ABSENT) {
                         CNode<K, V> rn = (cn.gen == gen) ? cn : cn.renewed (gen, ct);
-                        CNode<K, V> ncnode = rn.insertedAt (pos, flag, new SNode<K, V> (k, v, hc), gen);
-                        if (GCAS (cn, ncnode, ct))
+                        CNode<K, V> ncnode = rn.insertedAt (pos, flag, new SNode<> (k, v, hc), gen);
+                        if (GCAS (cn, ncnode, ct)) {
                             return Option.makeOption ();// None
-                        else
+                        } else {
                             return null;
+                        }
                     } else if (cond == INode.KEY_PRESENT) {
                         return Option.makeOption ();// None;
-                    } else 
+                    }
+                    else {
                         return Option.makeOption (); // None
+                    }
                 } else if (m instanceof TNode) {
                     clean (parent, ct, lev - 5);
                     return null;
@@ -352,39 +367,47 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                     LNode<K, V> ln = (LNode<K, V>) m;
                     if (cond == null) {
                         Option<V> optv = ln.get (k);
-                        if (insertln (ln, k, v, ct))
+                        if (insertln (ln, k, v, ct)) {
                             return optv;
-                        else
+                        } else {
                             return null;
+                        }
                     } else if (cond == INode.KEY_ABSENT) {
                         Option<V> t = ln.get (k);
                         if (t == null) {
-                            if (insertln (ln, k, v, ct))
+                            if (insertln (ln, k, v, ct)) {
                                 return Option.makeOption ();// None
-                            else
+                            } else {
                                 return null;
-                        } else
+                            }
+                        } else {
                             return t;
+                        }
                     } else if (cond == INode.KEY_PRESENT) {
                         Option<V> t = ln.get (k);
                         if (t != null) {
-                            if (insertln (ln, k, v, ct))
+                            if (insertln (ln, k, v, ct)) {
                                 return t;
-                            else
+                            } else {
                                 return null;
-                        } else
+                            }
+                        }
+                        else {
                             return null; // None
+                        }
                     } else {
                         Option<V> t = ln.get (k);
                         if (t != null) {
                             if (((Some<V>) t).get () == cond) {
-                                if (insertln (ln, k, v, ct))
-                                    return new Some<V> ((V) cond);
-                                else
+                                if (insertln (ln, k, v, ct)) {
+                                    return new Some<> ((V) cond);
+                                } else {
                                     return null;
+                                }
 
-                            } else
+                            } else {
                                 return Option.makeOption ();
+                            }
                         }
                     }
                 }
@@ -400,11 +423,11 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
 
         /**
          * Looks up the value associated with the key.
-         * 
+         *
          * @return null if no value has been found, RESTART if the operation
          *         wasn't successful, or any other value otherwise
          */
-        final Object rec_lookup (final K k, final int hc, int lev, INode<K, V> parent, final Gen startgen, final TrieMap<K, V> ct) {
+        final Object rec_lookup (final K k, final int hc, final int lev, final INode<K, V> parent, final Gen startgen, final TrieMap<K, V> ct) {
             while (true) {
                 MainNode<K, V> m = GCAS_READ (ct); // use -Yinline!
 
@@ -414,32 +437,35 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                     int idx = (hc >>> lev) & 0x1f;
                     int flag = 1 << idx;
                     int bmp = cn.bitmap;
-                    if ((bmp & flag) == 0)
+                    if ((bmp & flag) == 0) {
                         return null; // 1a) bitmap shows no binding
-                    else { // 1b) bitmap contains a value - descend
+                    else { // 1b) bitmap contains a value - descend
                         int pos = (bmp == 0xffffffff) ? idx : Integer.bitCount (bmp & (flag - 1));
                         final BasicNode sub = cn.array [pos];
                         if (sub instanceof INode) {
                             INode<K, V> in = (INode<K, V>) sub;
-                            if (ct.isReadOnly () || (startgen == ((INodeBase<K, V>) sub).gen))
+                            if (ct.isReadOnly () || (startgen == ((INodeBase<K, V>) sub).gen)) {
                                 return in.rec_lookup (k, hc, lev + 5, this, startgen, ct);
-                            else {
+                            else {
                                 if (GCAS (cn, cn.renewed (startgen, ct), ct)) {
                                     // return rec_lookup (k, hc, lev, parent,
                                     // startgen, ct);
                                     // Tailrec
                                     continue;
-                                } else
+                                }
+                                else {
                                     return RESTART; // used to be throw
                                                     // RestartException
+                                }
                             }
                         } else if (sub instanceof SNode) {
                             // 2) singleton node
                             SNode<K, V> sn = (SNode<K, V>) sub;
-                            if (((SNode) sub).hc == hc && equal (sn.k, k, ct))
+                            if (((SNode) sub).hc == hc && equal (sn.k, k, ct)) {
                                 return sn.v;
-                            else
+                            } else {
                                 return null;
+                            }
                         }
                     }
                 } else if (m instanceof TNode) {
@@ -455,21 +481,22 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             }
         }
 
-        private Object cleanReadOnly (final TNode<K, V> tn, final int lev, final INode<K, V> parent, final TrieMap<K, V> ct, K k, int hc) {
+        private Object cleanReadOnly (final TNode<K, V> tn, final int lev, final INode<K, V> parent, final TrieMap<K, V> ct, final K k, final int hc) {
             if (ct.nonReadOnly ()) {
                 clean (parent, ct, lev - 5);
                 return RESTART; // used to be throw RestartException
             } else {
-                if (tn.hc == hc && equal(tn.k, k, ct))
+                if (tn.hc == hc && equal(tn.k, k, ct)) {
                     return tn.v;
-                else
+                } else {
                     return null;
+                }
             }
         }
 
         /**
          * Removes the key associated with the given value.
-         * 
+         *
          * @param v
          *            if null, will remove the key irregardless of the value;
          *            otherwise removes only if binding contains that exact key
@@ -477,7 +504,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
          * @return null if not successful, an Option[V] indicating the previous
          *         value otherwise
          */
-        final Option<V> rec_remove (K k, V v, int hc, int lev, final INode<K, V> parent, final Gen startgen, final TrieMap<K, V> ct) {
+        final Option<V> rec_remove (final K k, final V v, final int hc, final int lev, final INode<K, V> parent, final Gen startgen, final TrieMap<K, V> ct) {
             MainNode<K, V> m = GCAS_READ (ct); // use -Yinline!
 
             if (m instanceof CNode) {
@@ -485,42 +512,46 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                 int idx = (hc >>> lev) & 0x1f;
                 int bmp = cn.bitmap;
                 int flag = 1 << idx;
-                if ((bmp & flag) == 0)
+                if ((bmp & flag) == 0) {
                     return Option.makeOption ();
-                else {
+                else {
                     int pos = Integer.bitCount (bmp & (flag - 1));
                     BasicNode sub = cn.array [pos];
                     Option<V> res = null;
                     if (sub instanceof INode) {
                         INode<K, V> in = (INode<K, V>) sub;
-                        if (startgen == in.gen)
+                        if (startgen == in.gen) {
                             res = in.rec_remove (k, v, hc, lev + 5, this, startgen, ct);
-                        else {
-                            if (GCAS (cn, cn.renewed (startgen, ct), ct))
+                        else {
+                            if (GCAS (cn, cn.renewed (startgen, ct), ct)) {
                                 res = rec_remove (k, v, hc, lev, parent, startgen, ct);
-                            else
+                            } else {
                                 res = null;
+                            }
                         }
 
                     } else if (sub instanceof SNode) {
                         SNode<K, V> sn = (SNode<K, V>) sub;
                         if (sn.hc == hc && equal (sn.k, k, ct) && (v == null || v.equals(sn.v))) {
                             MainNode<K, V> ncn = cn.removedAt (pos, flag, gen).toContracted (lev);
-                            if (GCAS (cn, ncn, ct))
+                            if (GCAS (cn, ncn, ct)) {
                                 res = Option.makeOption (sn.v);
-                            else
+                            } else {
                                 res = null;
-                        } else
+                            }
+                        } else {
                             res = Option.makeOption ();
+                        }
                     }
 
-                    if (res instanceof None || (res == null))
+                    if (res instanceof None || (res == null)) {
                         return res;
-                    else {
+                    else {
                         if (parent != null) { // never tomb at root
                             MainNode<K, V> n = GCAS_READ (ct);
-                            if (n instanceof TNode)
+                            if (n instanceof TNode) {
                                 cleanParent (n, parent, ct, hc, lev, startgen);
+                            }
                         }
 
                         return res;
@@ -534,20 +565,22 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                 if (v == null) {
                     Option<V> optv = ln.get (k);
                     MainNode<K, V> nn = ln.removed (k, ct);
-                    if (GCAS (ln, nn, ct))
+                    if (GCAS (ln, nn, ct)) {
                         return optv;
-                    else
+                    } else {
                         return null;
+                    }
                 } else {
                     Option<V> tmp = ln.get (k);
                     if (tmp instanceof Some) {
                         Some<V> tmp1 = (Some<V>) tmp;
                         if (tmp1.get () == v) {
                             MainNode<K, V> nn = ln.removed (k, ct);
-                            if (GCAS (ln, nn, ct))
+                            if (GCAS (ln, nn, ct)) {
                                 return tmp;
-                            else
+                            } else {
                                 return null;
+                            }
                         }
                     }
                 }
@@ -572,13 +605,14 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                             if (nonlive instanceof TNode) {
                                 TNode<K, V> tn = (TNode<K, V>) nonlive;
                                 MainNode<K, V> ncn = cn.updatedAt (pos, tn.copyUntombed (), gen).toContracted (lev - 5);
-                                if (!parent.GCAS (cn, ncn, ct))
+                                if (!parent.GCAS (cn, ncn, ct)) {
                                     if (ct.readRoot ().gen == startgen) {
                                         // cleanParent (nonlive, parent, ct, hc,
                                         // lev, startgen);
                                         // tailrec
                                         continue;
                                     }
+                                }
                             }
                         }
                     }
@@ -589,7 +623,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             }
         }
 
-        private void clean (final INode<K, V> nd, final TrieMap<K, V> ct, int lev) {
+        private void clean (final INode<K, V> nd, final TrieMap<K, V> ct, final int lev) {
             MainNode<K, V> m = nd.GCAS_READ (ct);
             if (m instanceof CNode) {
                 CNode<K, V> cn = (CNode<K, V>) m;
@@ -617,7 +651,8 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         // case x => "<elem: %s>".format(x)
         // })
 
-        public String string (int lev) {
+        @Override
+        public String string (final int lev) {
             return "INode";
         }
 
@@ -631,14 +666,17 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             WRITE_PREV (p);
         }
 
-        public String string (int lev) {
+        @Override
+        public String string (final int lev) {
             throw new UnsupportedOperationException ();
         }
 
-        public int cachedSize (Object ct) {
+        @Override
+        public int cachedSize (final Object ct) {
             throw new UnsupportedOperationException ();
         }
 
+        @Override
         public String toString () {
             return String.format ("FailedNode(%s)", p);
         }
@@ -660,22 +698,24 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         }
 
         final SNode<K, V> copy() {
-            return new SNode<K, V> (k, v, hc);
+            return new SNode<> (k, v, hc);
         }
 
         final TNode<K, V> copyTombed () {
-            return new TNode<K, V> (k, v, hc);
+            return new TNode<> (k, v, hc);
         }
 
         final SNode<K, V> copyUntombed () {
-            return new SNode<K, V> (k, v, hc);
+            return new SNode<> (k, v, hc);
         }
 
+        @Override
         final public Map.Entry<K, V> kvPair () {
-            return new SimpleImmutableEntry<K, V> (k, v);
+            return new SimpleImmutableEntry<> (k, v);
         }
 
-        final public String string (int lev) {
+        @Override
+        final public String string (final int lev) {
             // ("  " * lev) + "SNode(%s, %s, %x)".format(k, v, hc);
             return "SNode";
         }
@@ -693,26 +733,29 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         }
 
         final TNode<K, V> copy () {
-            return new TNode<K, V> (k, v, hc);
+            return new TNode<> (k, v, hc);
         }
 
         final TNode<K, V> copyTombed () {
-            return new TNode<K, V> (k, v, hc);
+            return new TNode<> (k, v, hc);
         }
 
         final SNode<K, V> copyUntombed () {
-            return new SNode<K, V> (k, v, hc);
+            return new SNode<> (k, v, hc);
         }
 
+        @Override
         final public Map.Entry<K, V> kvPair () {
-            return new SimpleImmutableEntry<K, V> (k, v);
+            return new SimpleImmutableEntry<> (k, v);
         }
 
-        final public int cachedSize (Object ct) {
+        @Override
+        final public int cachedSize (final Object ct) {
             return 1;
         }
 
-        final public String string (int lev) {
+        @Override
+        final public String string (final int lev) {
             // ("  " * lev) + "TNode(%s, %s, %x, !)".format(k, v, hc);
             return "TNode";
         }
@@ -725,39 +768,41 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             this.listmap = listmap;
         }
 
-        public LNode(K k, V v) {
+        public LNode(final K k, final V v) {
             this (ListMap.map (k, v));
         }
 
-        public LNode (K k1, V v1, K k2, V v2) {
+        public LNode (final K k1, final V v1, final K k2, final V v2) {
             this (ListMap.map (k1, v1, k2, v2));
         }
 
-        LNode<K, V> inserted (K k, V v) {
-            return new LNode<K, V> (listmap.add (k, v));
+        LNode<K, V> inserted (final K k, final V v) {
+            return new LNode<> (listmap.add (k, v));
         }
 
-        MainNode<K, V> removed (K k, final TrieMap<K, V> ct) {
+        MainNode<K, V> removed (final K k, final TrieMap<K, V> ct) {
             ListMap<K, V> updmap = listmap.remove (k);
-            if (updmap.size () > 1)
-                return new LNode<K, V> (updmap);
-            else {
+            if (updmap.size () > 1) {
+                return new LNode<> (updmap);
+            else {
                 Entry<K, V> kv = updmap.iterator ().next ();
                 // create it tombed so that it gets compressed on subsequent
                 // accesses
-                return new TNode<K, V> (kv.getKey (), kv.getValue (), ct.computeHash (kv.getKey ()));
+                return new TNode<> (kv.getKey (), kv.getValue (), ct.computeHash (kv.getKey ()));
             }
         }
 
-        Option<V> get (K k) {
+        Option<V> get (final K k) {
             return listmap.get (k);
         }
 
-        public int cachedSize (Object ct) {
+        @Override
+        public int cachedSize (final Object ct) {
             return listmap.size ();
         }
 
-        public String string (int lev) {
+        @Override
+        public String string (final int lev) {
             // (" " * lev) + "LNode(%s)".format(listmap.mkString(", "))
             return "LNode";
         }
@@ -776,14 +821,16 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         }
 
         // this should only be called from within read-only snapshots
-        final public int cachedSize (Object ct) {
+        @Override
+        final public int cachedSize (final Object ct) {
             int currsz = READ_SIZE ();
-            if (currsz != -1)
+            if (currsz != -1) {
                 return currsz;
-            else {
+            else {
                 int sz = computeSize ((TrieMap<K, V>) ct);
-                while (READ_SIZE () == -1)
+                while (READ_SIZE () == -1) {
                     CAS_SIZE (-1, sz);
+                }
                 return READ_SIZE ();
             }
         }
@@ -807,40 +854,41 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             while (i < array.length) {
                 int pos = (i + offset) % array.length;
                 BasicNode elem = array [pos];
-                if (elem instanceof SNode)
+                if (elem instanceof SNode) {
                     sz += 1;
-                else if (elem instanceof INode)
+                } else if (elem instanceof INode) {
                     sz += ((INode<K, V>) elem).cachedSize (ct);
+                }
                 i += 1;
             }
             return sz;
         }
 
-        final CNode<K, V> updatedAt (int pos, final BasicNode nn, final Gen gen) {
+        final CNode<K, V> updatedAt (final int pos, final BasicNode nn, final Gen gen) {
             int len = array.length;
             BasicNode[] narr = new BasicNode[len];
             System.arraycopy (array, 0, narr, 0, len);
             narr [pos] = nn;
-            return new CNode<K, V> (bitmap, narr, gen);
+            return new CNode<> (bitmap, narr, gen);
         }
 
-        final CNode<K, V> removedAt (int pos, int flag, final Gen gen) {
+        final CNode<K, V> removedAt (final int pos, final int flag, final Gen gen) {
             BasicNode[] arr = array;
             int len = arr.length;
             BasicNode[] narr = new BasicNode[len - 1];
             System.arraycopy (arr, 0, narr, 0, pos);
             System.arraycopy (arr, pos + 1, narr, pos, len - pos - 1);
-            return new CNode<K, V> (bitmap ^ flag, narr, gen);
+            return new CNode<> (bitmap ^ flag, narr, gen);
         }
 
-        final CNode<K, V> insertedAt (int pos, int flag, final BasicNode nn, final Gen gen) {
+        final CNode<K, V> insertedAt (final int pos, final int flag, final BasicNode nn, final Gen gen) {
             int len = array.length;
             int bmp = bitmap;
             BasicNode[] narr = new BasicNode[len + 1];
             System.arraycopy (array, 0, narr, 0, pos);
             narr [pos] = nn;
             System.arraycopy (array, pos, narr, pos + 1, len - pos);
-            return new CNode<K, V> (bmp | flag, narr, gen);
+            return new CNode<> (bmp | flag, narr, gen);
         }
 
         /**
@@ -857,31 +905,35 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                 if (elem instanceof INode) {
                     INode<K, V> in = (INode<K, V>) elem;
                     narr [i] = in.copyToGen (ngen, ct);
-                } else if (elem instanceof BasicNode)
+                } else if (elem instanceof BasicNode) {
                     narr [i] = elem;
+                }
                 i += 1;
             }
-            return new CNode<K, V> (bitmap, narr, ngen);
+            return new CNode<> (bitmap, narr, ngen);
         }
 
         private BasicNode resurrect (final INode<K, V> inode, final Object inodemain) {
             if (inodemain instanceof TNode) {
                 TNode<K, V> tn = (TNode<K, V>) inodemain;
                 return tn.copyUntombed ();
-            } else
+            } else {
                 return inode;
+            }
         }
 
-        final MainNode<K, V> toContracted (int lev) {
+        final MainNode<K, V> toContracted (final int lev) {
             if (array.length == 1 && lev > 0) {
                 if (array [0] instanceof SNode) {
                     SNode<K, V> sn = (SNode<K, V>) array [0];
                     return sn.copyTombed ();
-                } else
+                } else {
                     return this;
+                }
 
-            } else
+            } else {
                 return this;
+            }
         }
 
         // - if the branching factor is 1 for this CNode, and the child
@@ -890,7 +942,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         // returns the version of this node with at least some null-inodes
         // removed (those existing when the op began)
         // - if there are only null-i-nodes below, returns null
-        final MainNode<K, V> toCompressed (final TrieMap<K, V> ct, int lev, Gen gen) {
+        final MainNode<K, V> toCompressed (final TrieMap<K, V> ct, final int lev, final Gen gen) {
             int bmp = bitmap;
             int i = 0;
             BasicNode[] arr = array;
@@ -911,7 +963,8 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             return new CNode<K, V> (bmp, tmparray, gen).toContracted (lev);
         }
 
-        public String string (int lev) {
+        @Override
+        public String string (final int lev) {
             // "CNode %x\n%s".format(bitmap, array.map(_.string(lev +
             // 1)).mkString("\n"));
             return "CNode";
@@ -941,6 +994,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         // return null;
         // }
 
+        @Override
         public String toString () {
             // val elems = collectLocalElems
             // "CNode(sz: %d; %s)".format(elems.size,
@@ -948,24 +1002,25 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             return "CNode";
         }
 
-        static <K, V> MainNode<K,V> dual (final SNode<K, V> x, int xhc, final SNode<K, V> y, int yhc, int lev, Gen gen) {
+        static <K, V> MainNode<K,V> dual (final SNode<K, V> x, final int xhc, final SNode<K, V> y, final int yhc, final int lev, final Gen gen) {
             if (lev < 35) {
                 int xidx = (xhc >>> lev) & 0x1f;
                 int yidx = (yhc >>> lev) & 0x1f;
                 int bmp = (1 << xidx) | (1 << yidx);
 
                 if (xidx == yidx) {
-                    INode<K, V> subinode = new INode<K, V> (gen);// (TrieMap.inodeupdater)
+                    INode<K, V> subinode = new INode<> (gen);// (TrieMap.inodeupdater)
                     subinode.mainnode = dual (x, xhc, y, yhc, lev + 5, gen);
-                    return new CNode<K, V> (bmp, new BasicNode[] { subinode }, gen);
+                    return new CNode<> (bmp, new BasicNode[] { subinode }, gen);
                 } else {
-                    if (xidx < yidx)
-                        return new CNode<K, V> (bmp, new BasicNode[] { x, y }, gen);
-                    else
-                        return new CNode<K, V> (bmp, new BasicNode[] { y, x }, gen);
+                    if (xidx < yidx) {
+                        return new CNode<> (bmp, new BasicNode[] { x, y }, gen);
+                    } else {
+                        return new CNode<> (bmp, new BasicNode[] { y, x }, gen);
+                    }
                 }
             } else {
-                return new LNode<K, V> (x.k, x.v, y.k, y.v);
+                return new LNode<> (x.k, x.v, y.k, y.v);
             }
         }
 
@@ -988,7 +1043,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     private static class Equiv<K> implements Serializable {
         private static final long serialVersionUID = 1L;
 
-        public boolean equiv (K k1, K k2) {
+        public boolean equiv (final K k1, final K k2) {
             return k1.equals (k2);
         }
 
@@ -1002,7 +1057,8 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     static class Default<K> implements Hashing<K> {
         private static final long serialVersionUID = 1L;
 
-        public int hash (K k) {
+        @Override
+        public int hash (final K k) {
             int h = k.hashCode ();
             // This function ensures that hashCodes that differ only by
             // constant multiples at each bit position have a bounded
@@ -1033,7 +1089,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         this.readOnly = readOnly;
     }
 
-    TrieMap (final Object r, final Hashing<K> hashf, final Equiv<K> ef, boolean readOnly) {
+    TrieMap (final Object r, final Hashing<K> hashf, final Equiv<K> ef, final boolean readOnly) {
         this(hashf, ef, readOnly);
         this.root = r;
     }
@@ -1080,7 +1136,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     // } while (obj != TrieMapSerializationEnd);
     // }
 
-    final boolean CAS_ROOT (Object ov, Object nv) {
+    final boolean CAS_ROOT (final Object ov, final Object nv) {
         if (isReadOnly()) {
             throw new IllegalStateException("Attempted to modify a read-only snapshot");
         }
@@ -1088,7 +1144,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     }
 
     // FIXME: abort = false by default
-    final INode<K, V> readRoot (boolean abort) {
+    final INode<K, V> readRoot (final boolean abort) {
         return RDCSS_READ_ROOT (abort);
     }
 
@@ -1100,11 +1156,11 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         return RDCSS_READ_ROOT (false);
     }
 
-    final INode<K, V> RDCSS_READ_ROOT (boolean abort) {
+    final INode<K, V> RDCSS_READ_ROOT (final boolean abort) {
         Object r = /* READ */root;
-        if (r instanceof INode)
+        if (r instanceof INode) {
             return (INode<K, V>) r;
-        else if (r instanceof RDCSS_Descriptor) {
+        else if (r instanceof RDCSS_Descriptor) {
             return RDCSS_Complete (abort);
         }
         throw new RuntimeException ("Should not happen");
@@ -1113,18 +1169,18 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     private final INode<K, V> RDCSS_Complete (final boolean abort) {
         while (true) {
             Object v = /* READ */root;
-            if (v instanceof INode)
+            if (v instanceof INode) {
                 return (INode<K, V>) v;
-            else if (v instanceof RDCSS_Descriptor) {
+            else if (v instanceof RDCSS_Descriptor) {
                 RDCSS_Descriptor<K, V> desc = (RDCSS_Descriptor<K, V>) v;
                 INode<K, V> ov = desc.old;
                 MainNode<K, V> exp = desc.expectedmain;
                 INode<K, V> nv = desc.nv;
 
                 if (abort) {
-                    if (CAS_ROOT (desc, ov))
+                    if (CAS_ROOT (desc, ov)) {
                         return ov;
-                    else {
+                    else {
                         // return RDCSS_Complete (abort);
                         // tailrec
                         continue;
@@ -1141,9 +1197,9 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                             continue;
                         }
                     } else {
-                        if (CAS_ROOT (desc, ov))
+                        if (CAS_ROOT (desc, ov)) {
                             return ov;
-                        else {
+                        else {
                             // return RDCSS_Complete (abort);
                             // tailrec
                             continue;
@@ -1158,12 +1214,13 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     }
 
     private boolean RDCSS_ROOT (final INode<K, V> ov, final MainNode<K, V> expectedmain, final INode<K, V> nv) {
-        RDCSS_Descriptor<K, V> desc = new RDCSS_Descriptor<K, V> (ov, expectedmain, nv);
+        RDCSS_Descriptor<K, V> desc = new RDCSS_Descriptor<> (ov, expectedmain, nv);
         if (CAS_ROOT (ov, desc)) {
             RDCSS_Complete (false);
             return /* READ */desc.committed;
-        } else
+        } else {
             return false;
+        }
     }
 
     private void inserthc (final K k, final int hc, final V v) {
@@ -1187,8 +1244,9 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                 // return insertifhc (k, hc, v, cond);
                 // tailrec
                 continue;
-            } else
+            } else {
                 return ret;
+            }
         }
     }
 
@@ -1200,8 +1258,9 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                 // return lookuphc (k, hc);
                 // tailrec
                 continue;
-            } else
+            } else {
                 return res;
+            }
         }
     }
 
@@ -1209,9 +1268,9 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         while (true) {
             INode<K, V> r = RDCSS_READ_ROOT ();
             Option<V> res = r.rec_remove (k, v, hc, 0, null, r.gen, this);
-            if (res != null)
+            if (res != null) {
                 return res;
-            else {
+            else {
                 // return removehc (k, v, hc);
                 // tailrec
                 continue;
@@ -1257,7 +1316,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     /**
      * Returns a snapshot of this TrieMap. This operation is lock-free and
      * linearizable.
-     * 
+     *
      * The snapshot is lazily updated - the first time some branch in the
      * snapshot or this TrieMap are accessed, they are rewritten. This means
      * that the work of rebuilding both the snapshot and this TrieMap is
@@ -1269,9 +1328,9 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         while (true) {
             INode<K, V> r = RDCSS_READ_ROOT ();
             final MainNode<K, V> expmain = r.gcasRead (this);
-            if (RDCSS_ROOT (r, expmain, r.copyToGen (new Gen (), this)))
-                return new TrieMap<K, V> (r.copyToGen (new Gen (), this), hashing (), equality (), readOnly);
-            else {
+            if (RDCSS_ROOT (r, expmain, r.copyToGen (new Gen (), this))) {
+                return new TrieMap<> (r.copyToGen (new Gen (), this), hashing (), equality (), readOnly);
+            else {
                 // return snapshot ();
                 // tailrec
                 continue;
@@ -1282,33 +1341,35 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     /**
      * Returns a read-only snapshot of this TrieMap. This operation is lock-free
      * and linearizable.
-     * 
+     *
      * The snapshot is lazily updated - the first time some branch of this
      * TrieMap are accessed, it is rewritten. The work of creating the snapshot
      * is thus distributed across subsequent updates and accesses on this
      * TrieMap by all threads. Note that the snapshot itself is never rewritten
      * unlike when calling the `snapshot` method, but the obtained snapshot
      * cannot be modified.
-     * 
+     *
      * This method is used by other methods such as `size` and `iterator`.
      */
     final public TrieMap<K, V> readOnlySnapshot () {
         // Is it a snapshot of a read-only snapshot?
-        if(!nonReadOnly ())
+        if(!nonReadOnly ()) {
             return this;
-        
+        }
+
         while (true) {
             INode<K, V> r = RDCSS_READ_ROOT ();
             MainNode<K, V> expmain = r.gcasRead (this);
-            if (RDCSS_ROOT (r, expmain, r.copyToGen (new Gen (), this)))
-                return new TrieMap<K, V> (r, hashing (), equality (), true);
-            else {
+            if (RDCSS_ROOT (r, expmain, r.copyToGen (new Gen (), this))) {
+                return new TrieMap<> (r, hashing (), equality (), true);
+            else {
                 // return readOnlySnapshot ();
                 continue;
             }
         }
     }
 
+    @Override
     final public void clear () {
         while (true) {
             INode<K, V> r = RDCSS_READ_ROOT ();
@@ -1321,29 +1382,31 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     }
 
     // @inline
-    int computeHash (K k) {
+    int computeHash (final K k) {
         return hashingobj.hash (k);
     }
 
-    final V lookup (K k) {
+    final V lookup (final K k) {
         int hc = computeHash (k);
 //        return (V) lookuphc (k, hc);
         Object o = lookuphc (k, hc);
         if(o instanceof Some) {
             return ((Some<V>)o).get ();
-        } else if(o instanceof None) 
+        } else if(o instanceof None) {
             return null;
-        else
+        } else {
             return (V)o;
+        }
     }
 
-    final V apply (K k) {
+    final V apply (final K k) {
         int hc = computeHash (k);
         Object res = lookuphc (k, hc);
-        if (res == null)
+        if (res == null) {
             throw new NoSuchElementException ();
-        else
+        } else {
             return (V) res;
+        }
     }
 
 //    final public Option<V> get (K k) {
@@ -1351,135 +1414,142 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
 //        return Option.makeOption ((V)lookuphc (k, hc));
 //    }
 
-    final public V get (Object k) {
+    @Override
+    final public V get (final Object k) {
         return lookup((K)k);
     }
-    
-    final public Option<V> putOpt(Object key, Object value) {
+
+    final public Option<V> putOpt(final Object key, final Object value) {
         int hc = computeHash ((K)key);
         return insertifhc ((K)key, hc, (V)value, null);
     }
 
     @Override
-    final public V put (Object key, Object value) {
+    final public V put (final Object key, final Object value) {
         ensureReadWrite();
         int hc = computeHash ((K)key);
         Option<V> ov = insertifhc ((K)key, hc, (V)value, null);
         if(ov instanceof Some) {
             Some<V> sv = (Some<V>)ov;
             return sv.get ();
-        } else 
+        } else {
             return null;
+        }
     }
-    
-    final public void update (K k, V v) {
+
+    final public void update (final K k, final V v) {
         int hc = computeHash (k);
         inserthc (k, hc, v);
     }
 
-    final public TrieMap<K, V> add (K k, V v) {
+    final public TrieMap<K, V> add (final K k, final V v) {
         update (k, v);
         return this;
     }
 
-    final Option<V> removeOpt (K k) {
+    final Option<V> removeOpt (final K k) {
         int hc = computeHash (k);
         return removehc (k, (V) null, hc);
     }
 
     @Override
-    final public V remove (Object k) {
+    final public V remove (final Object k) {
         ensureReadWrite();
         int hc = computeHash ((K)k);
         Option<V> ov = removehc ((K)k, (V) null, hc);
         if(ov instanceof Some) {
             Some<V> sv = (Some<V>)ov;
             return sv.get();
-        } else 
+        } else {
             return null;
+        }
     }
-    
+
 //    final public TrieMap<K, V> remove (Object k) {
 //        removeOpt ((K)k);
 //        return this;
 //    }
 
-    final public Option<V> putIfAbsentOpt (K k, V v) {
+    final public Option<V> putIfAbsentOpt (final K k, final V v) {
         int hc = computeHash (k);
         return insertifhc (k, hc, v, INode.KEY_ABSENT);
     }
 
     @Override
-    final public V putIfAbsent (Object k, Object v) {
+    final public V putIfAbsent (final Object k, final Object v) {
         ensureReadWrite();
         int hc = computeHash ((K)k);
         Option<V> ov = insertifhc ((K)k, hc, (V)v, INode.KEY_ABSENT);
         if(ov instanceof Some) {
             Some<V> sv = (Some<V>)ov;
             return sv.get();
-        } else 
+        } else {
             return null;
+        }
     }
-    
+
     @Override
-    public boolean remove (Object k, Object v) {
+    public boolean remove (final Object k, final Object v) {
         ensureReadWrite();
         int hc = computeHash ((K)k);
         return removehc ((K)k, (V)v, hc).nonEmpty ();
     }
 
     @Override
-    public boolean replace (K k, V oldvalue, V newvalue) {
+    public boolean replace (final K k, final V oldvalue, final V newvalue) {
         ensureReadWrite();
         int hc = computeHash (k);
-        return insertifhc (k, hc, newvalue, (Object) oldvalue).nonEmpty ();
+        return insertifhc (k, hc, newvalue, oldvalue).nonEmpty ();
     }
 
-    public Option<V> replaceOpt (K k, V v) {
+    public Option<V> replaceOpt (final K k, final V v) {
         int hc = computeHash (k);
         return insertifhc (k, hc, v, INode.KEY_PRESENT);
     }
 
     @Override
-    public V replace (Object k, Object v) {
+    public V replace (final Object k, final Object v) {
         ensureReadWrite();
         int hc = computeHash ((K)k);
         Option<V> ov = insertifhc ((K)k, hc, (V)v, INode.KEY_PRESENT);
         if(ov instanceof Some) {
             Some<V> sv = (Some<V>)ov;
             return sv.get();
-        } else 
+        } else {
             return null;
+        }
     }
-    
+
     /***
      * Return an iterator over a TrieMap.
-     * 
+     *
      * If this is a read-only snapshot, it would return a read-only iterator.
-     * 
+     *
      * If it is the original TrieMap or a non-readonly snapshot, it would return
      * an iterator that would allow for updates.
-     * 
+     *
      * @return
      */
     public Iterator<Map.Entry<K, V>> iterator () {
-        if (!nonReadOnly ())
+        if (!nonReadOnly ()) {
             return readOnlySnapshot ().readOnlyIterator ();
-        else
-            return new TrieMapIterator<K, V> (0, this);
+        } else {
+            return new TrieMapIterator<> (0, this);
+        }
     }
 
     /***
      * Return an iterator over a TrieMap.
      * This is a read-only iterator.
-     * 
+     *
      * @return
      */
     public Iterator<Map.Entry<K, V>> readOnlyIterator () {
-        if (nonReadOnly ())
+        if (nonReadOnly ()) {
             return readOnlySnapshot ().readOnlyIterator ();
-        else
-            return new TrieMapReadOnlyIterator<K, V> (0, this);
+        } else {
+            return new TrieMapReadOnlyIterator<> (0, this);
+        }
     }
 
     private int cachedSize () {
@@ -1487,11 +1557,13 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         return r.cachedSize (this);
     }
 
+    @Override
     public int size () {
-        if (nonReadOnly ())
+        if (nonReadOnly ()) {
             return readOnlySnapshot ().size ();
-        else
+        } else {
             return cachedSize ();
+        }
     }
 
     String stringPrefix () {
@@ -1501,61 +1573,67 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     /***
      * This iterator is a read-only one and does not allow for any update
      * operations on the underlying data structure.
-     * 
+     *
      * @param <K>
      * @param <V>
      */
     private static class TrieMapReadOnlyIterator<K, V> extends TrieMapIterator<K, V> {
-        TrieMapReadOnlyIterator (int level, final TrieMap<K, V> ct, boolean mustInit) {
+        TrieMapReadOnlyIterator (final int level, final TrieMap<K, V> ct, final boolean mustInit) {
             super (level, ct, mustInit);
         }
 
-        TrieMapReadOnlyIterator (int level, TrieMap<K, V> ct) {
+        TrieMapReadOnlyIterator (final int level, final TrieMap<K, V> ct) {
             this (level, ct, true);
-        }        
+        }
+        @Override
         void initialize () {
             assert (ct.isReadOnly ());
             super.initialize ();
         }
-        
+
+        @Override
         public void remove () {
             throw new UnsupportedOperationException ("Operation not supported for read-only iterators");
         }
-        
+
+        @Override
         Map.Entry<K, V> nextEntry(final Map.Entry<K, V> rr) {
             // Return non-updatable entry
             return rr;
         }
     }
-    
+
     private static class TrieMapIterator<K, V> implements java.util.Iterator<Map.Entry<K, V>> {
         private int level;
         protected TrieMap<K, V> ct;
         private final boolean mustInit;
-        private BasicNode[][] stack = new BasicNode[7][];
-        private int[] stackpos = new int[7];
+        private final BasicNode[][] stack = new BasicNode[7][];
+        private final int[] stackpos = new int[7];
         private int depth = -1;
         private Iterator<Map.Entry<K, V>> subiter = null;
         private KVNode<K, V> current = null;
         private Map.Entry<K, V> lastReturned = null;
 
-        TrieMapIterator (int level, final TrieMap<K, V> ct, boolean mustInit) {
+        TrieMapIterator (final int level, final TrieMap<K, V> ct, final boolean mustInit) {
             this.level = level;
             this.ct = ct;
             this.mustInit = mustInit;
-            if (this.mustInit)
+            if (this.mustInit) {
                 initialize ();
+            }
         }
 
-        TrieMapIterator (int level, TrieMap<K, V> ct) {
+        TrieMapIterator (final int level, final TrieMap<K, V> ct) {
             this (level, ct, true);
         }
 
 
+        @Override
         public boolean hasNext () {
             return (current != null) || (subiter != null);
         }
 
+        @Override
         public Map.Entry<K, V> next () {
             if (hasNext ()) {
                 Map.Entry<K, V> r = null;
@@ -1566,10 +1644,10 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                     r = current.kvPair ();
                     advance ();
                 }
-                
+
                 lastReturned = r;
                 if(r instanceof Map.Entry) {
-                    final Map.Entry<K, V> rr = (Map.Entry<K, V>)r;
+                    final Map.Entry<K, V> rr = r;
                     return nextEntry(rr);
                 }
                 return r;
@@ -1578,7 +1656,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                 return null;
             }
         }
-        
+
         Map.Entry<K, V> nextEntry(final Map.Entry<K, V> rr) {
             return new Map.Entry<K, V>() {
                 private V updated = null;
@@ -1594,14 +1672,14 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                 }
 
                 @Override
-                public V setValue (V value) {
+                public V setValue (final V value) {
                     updated = value;
                     return ct.replace (getKey (), value);
                 }
-            };            
+            };
         }
 
-        private void readin (INode<K, V> in) {
+        private void readin (final INode<K, V> in) {
             MainNode<K, V> m = in.gcasRead (ct);
             if (m instanceof CNode) {
                 CNode<K, V> cn = (CNode<K, V>) m;
@@ -1649,15 +1727,16 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                     depth -= 1;
                     advance ();
                 }
-            } else
+            } else {
                 current = null;
+            }
         }
 
-        protected TrieMapIterator<K, V> newIterator (int _lev, TrieMap<K, V> _ct, boolean _mustInit) {
-            return new TrieMapIterator<K, V> (_lev, _ct, _mustInit);
+        protected TrieMapIterator<K, V> newIterator (final int _lev, final TrieMap<K, V> _ct, final boolean _mustInit) {
+            return new TrieMapIterator<> (_lev, _ct, _mustInit);
         }
 
-        protected void dupTo (TrieMapIterator<K, V> it) {
+        protected void dupTo (final TrieMapIterator<K, V> it) {
             it.level = this.level;
             it.ct = this.ct;
             it.depth = this.depth;
@@ -1668,9 +1747,9 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             System.arraycopy (this.stackpos, 0, it.stackpos, 0, 7);
 
             // this one needs to be evaluated
-            if (this.subiter == null)
+            if (this.subiter == null) {
                 it.subiter = null;
-            else {
+            else {
                 List<Map.Entry<K, V>> lst = toList (this.subiter);
                 this.subiter = lst.iterator ();
                 it.subiter = lst.iterator ();
@@ -1714,8 +1793,8 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         // Seq(this)
         // }
 
-        private List<Entry<K, V>> toList (Iterator<Entry<K, V>> it) {
-            ArrayList<Entry<K, V>> list = new ArrayList<Map.Entry<K, V>> ();
+        private List<Entry<K, V>> toList (final Iterator<Entry<K, V>> it) {
+            ArrayList<Entry<K, V>> list = new ArrayList<> ();
             while (it.hasNext ()) {
                 list.add (it.next ());
             }
@@ -1735,8 +1814,9 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
             if (lastReturned != null) {
                 ct.remove (lastReturned.getKey ());
                 lastReturned = null;
-            } else 
+            } else {
                 throw new IllegalStateException();
+            }
         }
 
     }
@@ -1746,7 +1826,8 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
     private static long TrieMapSerializationEnd = 0L - 7237891413820527142L;
 
 
-    public boolean containsKey (Object key) {
+    @Override
+    public boolean containsKey (final Object key) {
         return lookup ((K) key) != null;
     }
 
@@ -1761,7 +1842,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
      *
      */
     final class EntrySet extends AbstractSet<Map.Entry<K, V>> {
-        
+
         @Override
         public Iterator<Map.Entry<K, V>> iterator () {
             return TrieMap.this.iterator ();
@@ -1803,7 +1884,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         }
     }
 
-    private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
+    private void readObject(final ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
         inputStream.defaultReadObject();
         this.root = INode.newRootNode();
 
@@ -1823,7 +1904,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
         }
     }
 
-    private void writeObject(ObjectOutputStream outputStream) throws IOException {
+    private void writeObject(final ObjectOutputStream outputStream) throws IOException {
         outputStream.defaultWriteObject();
 
         final Map<K, V> ro = readOnlySnapshot();
index f0fbb55901ef3a8bf3c620481502891f151cb91e..456e9de21d7b06b72dfc3013d8d5c5edcacd5715 100644 (file)
@@ -1,34 +1,33 @@
 package org.opendaylight.yangtools.triemap;
 
 import java.util.Map;
-
 import org.junit.Test;
 
 public class TestCNodeFlagCollision {
     @Test
     public void testCNodeFlagCollision () {
-        final Map<Object, Object> map = new TrieMap<Object, Object> ();
+        final Map<Object, Object> map = new TrieMap<> ();
         final Integer z15169 = Integer.valueOf (15169);
         final Integer z28336 = Integer.valueOf (28336);
-        
+
         TestHelper.assertTrue (null == map.get (z15169));
         TestHelper.assertTrue (null == map.get (z28336));
-        
+
         map.put (z15169, z15169);
         TestHelper.assertTrue (null != map.get (z15169));
         TestHelper.assertTrue (null == map.get (z28336));
-        
+
         map.put (z28336, z28336);
         TestHelper.assertTrue (null != map.get (z15169));
         TestHelper.assertTrue (null != map.get (z28336));
-        
+
         map.remove (z15169);
-        
+
         TestHelper.assertTrue (null == map.get (z15169));
         TestHelper.assertTrue (null != map.get (z28336));
-        
+
         map.remove (z28336);
-        
+
         TestHelper.assertTrue (null == map.get (z15169));
         TestHelper.assertTrue (null == map.get (z28336));
     }
index b8ab573f8b134d3ef3eaff73e60e4684a79a589c..298fd4b44a55a581c65d761fef33367969f712b7 100644 (file)
@@ -1,19 +1,18 @@
 package org.opendaylight.yangtools.triemap;
 
 import java.util.Map;
-
 import org.junit.Test;
 
 public class TestCNodeInsertionIncorrectOrder {
 
     @Test
     public void testCNodeInsertionIncorrectOrder () {
-        final Map<Object, Object> map = new TrieMap<Object, Object> ();
+        final Map<Object, Object> map = new TrieMap<> ();
         final Integer z3884 = Integer.valueOf (3884);
         final Integer z4266 = Integer.valueOf (4266);
         map.put (z3884, z3884);
         TestHelper.assertTrue (null != map.get (z3884));
-        
+
         map.put (z4266, z4266);
         TestHelper.assertTrue (null != map.get (z3884));
         TestHelper.assertTrue (null != map.get (z4266));
index 9c29836174f90fb1541b11207ac10fdf8aab15ee..07b9d5fe49b1b1562e7c9a72d55e40906f7e9ef7 100644 (file)
@@ -1,7 +1,6 @@
 package org.opendaylight.yangtools.triemap;
 
 import java.util.concurrent.ConcurrentMap;
-
 import org.junit.Test;
 
 public class TestConcurrentMapPutIfAbsent {
@@ -9,8 +8,8 @@ public class TestConcurrentMapPutIfAbsent {
 
     @Test
     public void testConcurrentMapPutIfAbsent () {
-        final ConcurrentMap<Object, Object> map = new TrieMap<Object, Object> ();
-        
+        final ConcurrentMap<Object, Object> map = new TrieMap<> ();
+
         for (int i = 0; i < COUNT; i++) {
             TestHelper.assertTrue (null == map.putIfAbsent (i, i));
             TestHelper.assertTrue (Integer.valueOf (i).equals (map.putIfAbsent (i, i)));
index 980322d9dfadc5210655285405b13894a3de07b4..3086d9c17df75a51b991682cd751e13995ff2a98 100644 (file)
@@ -1,7 +1,6 @@
 package org.opendaylight.yangtools.triemap;
 
 import java.util.concurrent.ConcurrentMap;
-
 import org.junit.Test;
 
 public class TestConcurrentMapRemove {
@@ -9,8 +8,8 @@ public class TestConcurrentMapRemove {
 
     @Test
     public void testConcurrentMapRemove () {
-        final ConcurrentMap<Object, Object> map = new TrieMap<Object, Object> ();
-        
+        final ConcurrentMap<Object, Object> map = new TrieMap<> ();
+
         for (int i = 128; i < COUNT; i++) {
             TestHelper.assertFalse (map.remove (i, i));
             TestHelper.assertTrue (null == map.put (i, i));
index 6e10ecae10dd0801d7e5226e47be4bf04310b648..37f833392ab8189af1e8463fbe22f23773b9323a 100644 (file)
@@ -1,7 +1,6 @@
 package org.opendaylight.yangtools.triemap;
 
 import java.util.concurrent.ConcurrentMap;
-
 import org.junit.Test;
 
 public class TestConcurrentMapReplace {
@@ -9,8 +8,8 @@ public class TestConcurrentMapReplace {
 
     @Test
     public void testConcurrentMapReplace () {
-        final ConcurrentMap<Object, Object> map = new TrieMap<Object, Object> ();
-        
+        final ConcurrentMap<Object, Object> map = new TrieMap<> ();
+
         for (int i = 0; i < COUNT; i++) {
             TestHelper.assertTrue (null == map.replace (i, "lol"));
             TestHelper.assertFalse (map.replace (i, i, "lol2"));
index 8cd1b39d32f465b1a75f1b5ede4109e613325f7f..f0f0c67a183bbec2276f69e01e954abcd72afc45 100644 (file)
@@ -5,18 +5,18 @@ import org.junit.Test;
 public class TestDelete {
     @Test
     public void testDelete () {
-        final TrieMap<Object, Object> bt = new TrieMap<Object, Object> ();
+        final TrieMap<Object, Object> bt = new TrieMap<> ();
 
         for (int i = 0; i < 10000; i++) {
             TestHelper.assertEquals (null, bt.put (Integer.valueOf (i), Integer.valueOf (i)));
             final Object lookup = bt.lookup (Integer.valueOf (i));
             TestHelper.assertEquals (Integer.valueOf (i), lookup);
         }
-        
+
         checkAddInsert (bt, 536);
         checkAddInsert (bt, 4341);
         checkAddInsert (bt, 8437);
-        
+
         for (int i = 0; i < 10000; i++) {
             boolean removed = null != bt.remove(Integer.valueOf (i));
             TestHelper.assertEquals (Boolean.TRUE, Boolean.valueOf (removed));
@@ -27,7 +27,7 @@ public class TestDelete {
         bt.toString ();
     }
 
-    private static void checkAddInsert (final TrieMap<Object, Object> bt, int k) {
+    private static void checkAddInsert (final TrieMap<Object, Object> bt, final int k) {
         final Integer v = Integer.valueOf (k);
         bt.remove (v);
         Object foundV = bt.lookup (v);
@@ -35,7 +35,7 @@ public class TestDelete {
         TestHelper.assertEquals (null, bt.put (v, v));
         foundV = bt.lookup (v);
         TestHelper.assertEquals (v, foundV);
-        
+
         TestHelper.assertEquals (v, bt.put (v, Integer.valueOf (-1)));
         TestHelper.assertEquals (Integer.valueOf (-1), bt.put (v, v));
     }
index 963953718b5af381d1065294730d8a68b7d25120..b422a0bf51833f9725f487a499534a8e8803ac6e 100644 (file)
@@ -6,13 +6,13 @@ import org.junit.Test;
 public class TestHashCollisions {
     @Test
     public void testHashCollisions () {
-        final TrieMap<Object, Object> bt = new TrieMap<Object, Object> ();
+        final TrieMap<Object, Object> bt = new TrieMap<> ();
 
         insertStrings (bt);
         insertChars (bt);
         insertInts (bt);
         insertBytes (bt);
-        
+
         removeStrings (bt);
         removeChars (bt);
         removeInts (bt);
index 5cdcce6ec4535fcc30886709dc7b08fa679b7d37..ff78068f91ddca5cb2cb024178f4ad744510b20e 100644 (file)
@@ -1,13 +1,12 @@
 package org.opendaylight.yangtools.triemap;
 
 import java.util.Map;
-
 import org.junit.Test;
 
 public class TestHashCollisionsRemove {
     @Test
     public void  testHashCollisionsRemove() {
-        final Map<Object, Object> bt = new TrieMap<Object, Object> ();
+        final Map<Object, Object> bt = new TrieMap<> ();
         int count = 50000;
         for (int j = 0; j < count; j++) {
             final Object[] objects = TestMultiThreadMapIterator.getObjects (j);
@@ -15,7 +14,7 @@ public class TestHashCollisionsRemove {
                 bt.put (o, o);
             }
         }
-        
+
         for (int j = 0; j < count; j++) {
             final Object[] objects = TestMultiThreadMapIterator.getObjects (j);
             for (final Object o : objects) {
index 2f67c7834fedf588026c4877256f3a98ff81ccf4..32eb7d1fed55fe2ca6d93fb8e0afcb58bb43bb7a 100644 (file)
@@ -5,19 +5,18 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import org.junit.Test;
 
 public class TestHashCollisionsRemoveIterator {
     @Test
     public void testHashCollisionsRemoveIterator () {
-        final Map<Object, Object> bt = new TrieMap<Object, Object> ();
+        final Map<Object, Object> bt = new TrieMap<> ();
         int count = 50000;
         for (int j = 0; j < count; j++) {
             bt.put (Integer.valueOf (j), Integer.valueOf (j));
         }
-        
-        final Collection<Object> list = new ArrayList <Object> ();
+
+        final Collection<Object> list = new ArrayList <> ();
         for (final Iterator<Map.Entry<Object, Object>> i = bt.entrySet ().iterator (); i.hasNext ();) {
             final Entry<Object, Object> e = i.next ();
             final Object key = e.getKey ();
index 80846eaa7a27145f9b84e95843016a2655928020..a4c1a90e64e043b06ea47cd23c053a883734ca0f 100644 (file)
@@ -4,23 +4,23 @@ import org.junit.Assert;
 
 public class TestHelper {
 
-    public static void assertEquals (long expected, long found) {
+    public static void assertEquals (final long expected, final long found) {
         Assert.assertEquals (expected, found);
     }
 
-    public static void assertEquals (int expected, int found) {
+    public static void assertEquals (final int expected, final int found) {
         Assert.assertEquals (expected, found);
     }
 
-    public static void assertEquals (Object expected, Object found) {
+    public static void assertEquals (final Object expected, final Object found) {
         Assert.assertEquals (expected, found);
     }
 
-    public static void assertTrue (boolean found) {
+    public static void assertTrue (final boolean found) {
         Assert.assertTrue (found);
     }
 
-    public static void assertFalse (boolean found) {
+    public static void assertFalse (final boolean found) {
         Assert.assertFalse (found);
     }
 
index ee8db2d4374a7ba607b75eb173975825625d78fa..e1edc803435d0afa20864b276f1c19a3f2146270 100644 (file)
@@ -5,7 +5,7 @@ import org.junit.Test;
 public class TestInsert {
     @Test
     public void testInsert () {
-        final TrieMap<Object, Object> bt = new TrieMap<Object, Object> ();
+        final TrieMap<Object, Object> bt = new TrieMap<> ();
         TestHelper.assertEquals (null, bt.put ("a", "a"));
         TestHelper.assertEquals (null, bt.put ("b", "b"));
         TestHelper.assertEquals (null, bt.put ("c", "b"));
index 43abcc18bae5cc3a998dddf65a07880a3b08c371..221e0be75eda2040fdb128a2661b78aafbe12671 100644 (file)
@@ -6,7 +6,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Random;
 import java.util.Set;
-
 import org.junit.Test;
 
 public class TestMapIterator {
@@ -14,12 +13,12 @@ public class TestMapIterator {
     public void testMapIterator () {
         for (int i = 0; i < 60 * 1000; i+= 400 + new Random ().nextInt (400)) {
             System.out.println (i);
-            final Map<Integer, Integer> bt = new TrieMap <Integer, Integer> ();
+            final Map<Integer, Integer> bt = new TrieMap <> ();
             for (int j = 0; j < i; j++) {
                 TestHelper.assertEquals (null, bt.put (Integer.valueOf (j), Integer.valueOf (j)));
             }
             int count = 0;
-            final Set<Integer> set = new HashSet<Integer> ();
+            final Set<Integer> set = new HashSet<> ();
             for (final Map.Entry<Integer, Integer> e : bt.entrySet ()) {
                 set.add (e.getKey ());
                 count++;
@@ -33,9 +32,8 @@ public class TestMapIterator {
 
             TestHelper.assertEquals (i, count);
             TestHelper.assertEquals (i, bt.size ());
-            
-            for (final Iterator<Map.Entry<Integer, Integer>> iter = bt.entrySet ().iterator (); iter.hasNext ();) {
-                final Entry<Integer, Integer> e = iter.next ();
+
+            for (Entry<Integer, Integer> e : bt.entrySet ()) {
                 TestHelper.assertTrue (e.getValue () == bt.get (e.getKey ()));
                 e.setValue (e.getValue () + 1);
                 TestHelper.assertTrue (e.getValue () == e.getKey () + 1);
@@ -49,7 +47,7 @@ public class TestMapIterator {
                 iter.remove ();
                 TestHelper.assertFalse (bt.containsKey (k));
             }
-            
+
             TestHelper.assertEquals (0, bt.size ());
             TestHelper.assertTrue (bt.isEmpty ());
         }
index efcb846a9b63b4323af6cfcf222fa722407fd7e7..0e81419671cb8400ee18bf453b47ec53215b3fd2 100644 (file)
@@ -4,7 +4,6 @@ import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Test;
 
 public class TestMultiThreadAddDelete {
@@ -15,8 +14,8 @@ public class TestMultiThreadAddDelete {
     @Test
     public void testMultiThreadAddDelete () {
         for (int j = 0; j < RETRIES; j++) {
-            final Map<Object, Object> bt = new TrieMap <Object, Object> ();
-            
+            final Map<Object, Object> bt = new TrieMap <> ();
+
             {
                 final ExecutorService es = Executors.newFixedThreadPool (N_THREADS);
                 for (int i = 0; i < N_THREADS; i++) {
@@ -39,10 +38,10 @@ public class TestMultiThreadAddDelete {
                     e.printStackTrace ();
                 }
             }
-            
+
             TestHelper.assertEquals (COUNT, bt.size ());
             TestHelper.assertFalse (bt.isEmpty ());
-            
+
             {
                 final ExecutorService es = Executors.newFixedThreadPool (N_THREADS);
                 for (int i = 0; i < N_THREADS; i++) {
@@ -65,11 +64,11 @@ public class TestMultiThreadAddDelete {
                     e.printStackTrace ();
                 }
             }
-            
-            
+
+
             TestHelper.assertEquals (0, bt.size ());
             TestHelper.assertTrue (bt.isEmpty ());
-            
+
             {
                 final ExecutorService es = Executors.newFixedThreadPool (N_THREADS);
                 for (int i = 0; i < N_THREADS; i++) {
@@ -103,7 +102,7 @@ public class TestMultiThreadAddDelete {
                     e.printStackTrace ();
                 }
             }
-            
+
             TestHelper.assertEquals (0, bt.size ());
             if (!bt.isEmpty ()) {
                 System.out.println ();
index 6ad60fd41f4b90be2e23786de7a51ae688a7ee42..a0933116aec8175d9c343722682589056c279147 100644 (file)
@@ -3,7 +3,6 @@ package org.opendaylight.yangtools.triemap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Test;
 
 public class TestMultiThreadInserts {
@@ -11,7 +10,7 @@ public class TestMultiThreadInserts {
     public void testMultiThreadInserts () {
         final int nThreads = 2;
         final ExecutorService es = Executors.newFixedThreadPool (nThreads);
-        final TrieMap<Object, Object> bt = new TrieMap<Object, Object> ();
+        final TrieMap<Object, Object> bt = new TrieMap<> ();
         for (int i = 0; i < nThreads; i++) {
             final int threadNo = i;
             es.execute (new Runnable () {
@@ -32,7 +31,7 @@ public class TestMultiThreadInserts {
         } catch (final InterruptedException e) {
             e.printStackTrace ();
         }
-        
+
         for (int j = 0; j < 500 * 1000; j++) {
             final Object lookup = bt.lookup (Integer.valueOf (j));
             TestHelper.assertEquals (Integer.valueOf (j), lookup);
index fc4128a552c3368844283b46f0eb0f09947c9f95..dffaa1ee161641e76ca2012f5447faeaae461412 100644 (file)
@@ -9,7 +9,6 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Test;
 
 public class TestMultiThreadMapIterator {
@@ -17,7 +16,7 @@ public class TestMultiThreadMapIterator {
 
     @Test
     public void testMultiThreadMapIterator () {
-        final Map<Object, Object> bt = new TrieMap<Object, Object> ();
+        final Map<Object, Object> bt = new TrieMap<> ();
         for (int j = 0; j < 50 * 1000; j++) {
             final Object[] objects = getObjects (j);
             for (final Object o : objects) {
@@ -25,7 +24,7 @@ public class TestMultiThreadMapIterator {
             }
         }
 
-      System.out.println ("Size of initialized map is " + bt.size ());  
+      System.out.println ("Size of initialized map is " + bt.size ());
       int count = 0;
         {
             final ExecutorService es = Executors.newFixedThreadPool (NTHREADS);
@@ -34,10 +33,9 @@ public class TestMultiThreadMapIterator {
                 es.execute (new Runnable () {
                     @Override
                     public void run () {
-                        for (final Iterator<Map.Entry<Object, Object>> i = bt.entrySet ().iterator (); i.hasNext ();) {
-                            final Entry<Object, Object> e = i.next ();
+                        for (Entry<Object, Object> e : bt.entrySet ()) {
                             if (accepts (threadNo, NTHREADS, e.getKey ())) {
-                                String newValue = "TEST:" + threadNo; 
+                                String newValue = "TEST:" + threadNo;
                                 e.setValue (newValue);
                             }
                         }
@@ -55,13 +53,13 @@ public class TestMultiThreadMapIterator {
 
         count = 0;
         for (final Map.Entry<Object, Object> kv : bt.entrySet ()) {
-            Object value = kv.getValue (); 
+            Object value = kv.getValue ();
             TestHelper.assertTrue (value instanceof String);
             count++;
         }
         TestHelper.assertEquals (50000 + 2000 + 1000 + 100, count);
-        
-        final ConcurrentHashMap<Object, Object> removed = new ConcurrentHashMap<Object, Object> ();
+
+        final ConcurrentHashMap<Object, Object> removed = new ConcurrentHashMap<> ();
 
         {
             final ExecutorService es = Executors.newFixedThreadPool (NTHREADS);
@@ -112,11 +110,12 @@ public class TestMultiThreadMapIterator {
     }
 
     protected static boolean accepts (final int threadNo, final int nThreads, final Object key) {
-        int val = getKeyValue (key); 
-        if(val>=0)
+        int val = getKeyValue (key);
+        if(val>=0) {
             return val % nThreads == threadNo;
-        else
+        } else {
             return false;
+        }
     }
 
     private static int getKeyValue (final Object key) {
@@ -132,13 +131,14 @@ public class TestMultiThreadMapIterator {
         }
         else if (key instanceof Byte) {
             val = ((Byte) key).intValue () + 3;
-        } else 
+        } else {
             return -1;
+        }
         return val;
     }
 
     static Object[] getObjects (final int j) {
-        final Collection<Object> results = new LinkedList<Object> ();
+        final Collection<Object> results = new LinkedList<> ();
         results.add (Integer.valueOf (j));
         if (j < 2000) {
             results.add (Character.valueOf ((char) j));
index 878aa769d8de2800e3c3c01f6f6b10052dbe2d29..553d184089f866ec0245da61654f9eb8d9207737 100644 (file)
@@ -2,28 +2,27 @@ package org.opendaylight.yangtools.triemap;
 
 import java.util.Iterator;
 import java.util.Map.Entry;
-
 import org.junit.Before;
 import org.junit.Test;
 
 /***
- * 
+ *
  * Test that read-only iterators do not allow for any updates.
- * Test that non read-only iterators allow for updates. 
+ * Test that non read-only iterators allow for updates.
  *
  */
 public class TestReadOnlyAndUpdatableIterators {
     TrieMap<Integer, Integer> bt;
     private static final int MAP_SIZE = 200;
-    
+
     @Before
     public void setUp() {
-        bt = new TrieMap <Integer, Integer> ();
+        bt = new TrieMap <> ();
         for (int j = 0; j < MAP_SIZE; j++) {
             TestHelper.assertEquals (null, bt.put (Integer.valueOf (j), Integer.valueOf (j)));
-        }                
+        }
     }
-    
+
     @Test
     public void testReadOnlyIterator () {
         Iterator<Entry<Integer, Integer>> it = bt.readOnlyIterator ();
@@ -32,14 +31,14 @@ public class TestReadOnlyAndUpdatableIterators {
             // It should have generated an exception, because it is a read-only iterator
             TestHelper.assertFalse (true);
         } catch (Exception e) {
-            
+
         }
         try {
             it.remove ();
             // It should have generated an exception, because it is a read-only iterator
             TestHelper.assertFalse (true);
         } catch (Exception e) {
-            
+
         }
     }
 
@@ -52,14 +51,14 @@ public class TestReadOnlyAndUpdatableIterators {
             // It should have generated an exception, because it is a read-only iterator
             TestHelper.assertFalse (true);
         } catch (Exception e) {
-            
+
         }
         try {
             it.remove ();
             // It should have generated an exception, because it is a read-only iterator
             TestHelper.assertFalse (true);
         } catch (Exception e) {
-            
+
         }
     }
 
@@ -72,14 +71,14 @@ public class TestReadOnlyAndUpdatableIterators {
             // It should have generated an exception, because it is a read-only iterator
             TestHelper.assertFalse (true);
         } catch (Exception e) {
-            
+
         }
         try {
             it.remove ();
             // It should have generated an exception, because it is a read-only iterator
             TestHelper.assertFalse (true);
         } catch (Exception e) {
-            
+
         }
     }
 
@@ -90,18 +89,18 @@ public class TestReadOnlyAndUpdatableIterators {
             it.next().setValue (0);
         } catch (Exception e) {
             // It should not have generated an exception, because it is a non read-only iterator
-            TestHelper.assertFalse (true);            
+            TestHelper.assertFalse (true);
         }
-        
+
         try {
             it.remove ();
         } catch (Exception e) {
             // It should not have generated an exception, because it is a non read-only iterator
-            TestHelper.assertFalse (true);            
+            TestHelper.assertFalse (true);
         }
-        
+
         // All changes are done on the original map
-        TestHelper.assertEquals (MAP_SIZE - 1, bt.size ());            
+        TestHelper.assertEquals (MAP_SIZE - 1, bt.size ());
     }
 
     @Test
@@ -112,19 +111,19 @@ public class TestReadOnlyAndUpdatableIterators {
             it.next().setValue (0);
         } catch (Exception e) {
             // It should not have generated an exception, because it is a non read-only iterator
-            TestHelper.assertFalse (true);            
+            TestHelper.assertFalse (true);
         }
         try {
             it.remove ();
         } catch (Exception e) {
             // It should not have generated an exception, because it is a non read-only iterator
-            TestHelper.assertFalse (true);            
+            TestHelper.assertFalse (true);
         }
 
         // All changes are done on the snapshot, not on the original map
         // Map size should remain unchanged
         TestHelper.assertEquals (MAP_SIZE, bt.size ());
         // snapshot size was changed
-        TestHelper.assertEquals (MAP_SIZE-1, snapshot.size ());            
+        TestHelper.assertEquals (MAP_SIZE-1, snapshot.size ());
     }
 }
index 8f7db039076c3ee8e0182d67081cff178b50a679..d39a4829359610da62d36260bac36447c1b095ff 100644 (file)
@@ -5,14 +5,13 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-
 import org.junit.Assert;
 import org.junit.Test;
 
 public class TestSerialization {
     @Test
     public void testSerialization() throws IOException, ClassNotFoundException {
-        TrieMap<String, String> map = new TrieMap<String, String>();
+        TrieMap<String, String> map = new TrieMap<>();
 
         map.put("dude-0", "tom");
         map.put("dude-1", "john");