Correct Spliterator characteristics
[yangtools.git] / third-party / triemap / src / main / java / org / opendaylight / yangtools / triemap / LNodeEntry.java
index 66c11b721b6a3eef26c42af50969fb9eaef8e961..6a72ccaae4fb10d0ab9c4cd91e077a4b135b91a1 100644 (file)
  */
 package org.opendaylight.yangtools.triemap;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.Map.Entry;
+
 /**
- * A single entry in {@link LNodeEntries}.
+ * A single entry in {@link LNodeEntries}, implements {@link Entry} in order to prevent instantiation of objects for
+ * iteration.
  *
  * @author Robert Varga
  *
  * @param <K> the type of key
  * @param <V> the type of value
  */
-abstract class LNodeEntry<K, V> {
-    private final V value;
+abstract class LNodeEntry<K, V> implements Entry<K, V> {
     private final K key;
+    private final V value;
 
     LNodeEntry(final K key, final V value) {
-        this.value = value;
         this.key = key;
+        this.value = value;
     }
 
-    final K key() {
+    @Override
+    public final K getKey() {
         return key;
     }
 
-    final V value() {
+    @Override
+    public final V getValue() {
         return value;
     }
 
+    @Override
+    public final V setValue(final V value) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public final int hashCode() {
+        return EntryUtil.hash(key, value);
+    }
+
+    @SuppressFBWarnings(value = "EQ_UNUSUAL",  justification = "Equality handled by utility methods")
+    @Override
+    public final boolean equals(final Object obj) {
+        return EntryUtil.equal(obj, key, value);
+    }
+
+    @Override
+    public final String toString() {
+        return EntryUtil.string(key, value);
+    }
 }