BUG-7464: Hide LNode's listmap
[yangtools.git] / third-party / triemap / src / main / java / org / opendaylight / yangtools / triemap / LNode.java
index 3aad0d70c2e24224369302dcea2dc666024f8ea1..2f2c96c0e594d72ce7a1e23ea4d01c5a65649115 100644 (file)
  */
 package org.opendaylight.yangtools.triemap;
 
+import java.util.Iterator;
 import java.util.Map.Entry;
 
-final class LNode<K, V> extends MainNode<K, V> {
-    final ListMap<K, V> listmap;
+final class LNode<K, V> extends MainNode<K, V> implements Iterable<Entry<K, V>> {
+    private final ListMap<K, V> listmap;
 
-    LNode(final ListMap<K, V> listmap) {
+    private LNode(final ListMap<K, V> listmap) {
         this.listmap = listmap;
     }
 
-    LNode(final K k, final V v) {
-        this(ListMap.map(k, v));
-    }
-
     LNode(final K k1, final V v1, final K k2, final V v2) {
         this(ListMap.map(k1, v1, k2, v2));
     }
 
     LNode<K, V> inserted(final K k, final V v) {
-        return new LNode<> (listmap.add (k, v));
+        return new LNode<>(listmap.add(k, v));
     }
 
-    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<> (updmap);
+    MainNode<K, V> removed(final K k, final TrieMap<K, V> ct) {
+        final ListMap<K, V> updmap = listmap.remove(k);
+        if (updmap.size() > 1) {
+            return new LNode<>(updmap);
         }
 
         final Entry<K, V> kv = updmap.iterator().next();
@@ -52,7 +49,7 @@ final class LNode<K, V> extends MainNode<K, V> {
     }
 
     @Override
-    public int cachedSize(final Object ct) {
+    int cachedSize(final TrieMap<K, V> ct) {
         return listmap.size();
     }
 
@@ -61,4 +58,9 @@ final class LNode<K, V> extends MainNode<K, V> {
         // (" " * lev) + "LNode(%s)".format(listmap.mkString(", "))
         return "LNode";
     }
+
+    @Override
+    public Iterator<Entry<K, V>> iterator() {
+        return listmap.iterator();
+    }
 }
\ No newline at end of file