Bump upstreams
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / LazyBindingMapIterState.java
index 8c7612f42f514492601a119112a2c32b62223664..dac19d9d7ffea94674559d0726e0f3bfb4bb436e 100644 (file)
@@ -13,6 +13,7 @@ import static org.opendaylight.mdsal.binding.dom.codec.impl.LazyBindingList.OBJ_
 import com.google.common.collect.AbstractIterator;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterators;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.invoke.VarHandle;
@@ -23,8 +24,8 @@ import java.util.Map.Entry;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.binding.Key;
+import org.opendaylight.yangtools.yang.binding.KeyAware;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,7 +36,7 @@ import org.slf4j.LoggerFactory;
  * @param <K> key type
  * @param <V> value type
  */
-final class LazyBindingMapIterState<K extends Identifier<V>, V extends DataObject & Identifiable<K>>
+final class LazyBindingMapIterState<K extends Key<V>, V extends DataObject & KeyAware<K>>
         extends LazyBindingMap.State<K, V> {
     private static final Logger LOG = LoggerFactory.getLogger(LazyBindingMapIterState.class);
     private static final VarHandle ENTRY_SET;
@@ -58,12 +59,15 @@ final class LazyBindingMapIterState<K extends Identifier<V>, V extends DataObjec
 
     // Secondary views derived from values, used via varhandles above
     @SuppressWarnings("unused")
+    @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "https://github.com/spotbugs/spotbugs/issues/2749")
     private volatile KeySet<K, V> keySet;
     @SuppressWarnings("unused")
+    @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "https://github.com/spotbugs/spotbugs/issues/2749")
     private volatile EntrySet<K, V> entrySet;
 
     // Lookup map, instantiated on demand, used via varhandle above
     @SuppressWarnings("unused")
+    @SuppressFBWarnings(value = "URF_UNREAD_FIELD", justification = "https://github.com/spotbugs/spotbugs/issues/2749")
     private volatile ImmutableMap<K, V> lookupMap;
 
     LazyBindingMapIterState(final LazyBindingMap<K, V> map) {
@@ -131,7 +135,7 @@ final class LazyBindingMapIterState<K extends Identifier<V>, V extends DataObjec
         return (witness = KEY_SET.compareAndExchangeRelease(this, null, ret)) == null ? ret : (KeySet<K, V>) witness;
     }
 
-    private static final class EntrySet<K extends Identifier<V>, V extends DataObject & Identifiable<K>>
+    private static final class EntrySet<K extends Key<V>, V extends DataObject & KeyAware<K>>
             extends AbstractSet<Entry<K, V>> implements Immutable {
         private final Values<K, V> values;
 
@@ -158,7 +162,7 @@ final class LazyBindingMapIterState<K extends Identifier<V>, V extends DataObjec
         }
     }
 
-    private static final class KeySet<K extends Identifier<V>, V extends DataObject & Identifiable<K>>
+    private static final class KeySet<K extends Key<V>, V extends DataObject & KeyAware<K>>
             extends AbstractSet<K> implements Immutable {
         private final Values<K, V> values;
 
@@ -173,7 +177,7 @@ final class LazyBindingMapIterState<K extends Identifier<V>, V extends DataObjec
 
         @Override
         public Iterator<K> iterator() {
-            return Iterators.transform(values.iterator(), value -> value.key());
+            return Iterators.transform(values.iterator(), KeyAware::key);
         }
 
         @Override
@@ -188,14 +192,14 @@ final class LazyBindingMapIterState<K extends Identifier<V>, V extends DataObjec
      * the array to hold all values upfront and populate it with MapEntry nodes. That allows us to perform lock-free
      * access, as we just end up CASing MapEntryNodes with their Binding replacements.
      */
-    private static final class Values<K extends Identifier<V>, V extends DataObject & Identifiable<K>>
+    private static final class Values<K extends Key<V>, V extends DataObject & KeyAware<K>>
             extends AbstractSet<V> implements Immutable {
         private final LazyBindingMap<K, V> map;
         private final Object[] objects;
 
         Values(final LazyBindingMap<K, V> map) {
             this.map = requireNonNull(map);
-            objects = map.mapNode().getValue().toArray();
+            objects = map.mapNode().body().toArray();
         }
 
         @Override