Remove redundant type arguments
[yangtools.git] / common / util / src / main / java / org / opendaylight / yangtools / util / ImmutableOffsetMap.java
index 3da4c38fb2a21cc1c1bcd9afe6b48233055e58e9..844086df746c1c314f3a2625dd1aa268543cc0ef 100644 (file)
@@ -13,6 +13,7 @@ import static java.util.Objects.requireNonNull;
 import com.google.common.annotations.Beta;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.UnmodifiableIterator;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -161,8 +162,7 @@ public abstract class ImmutableOffsetMap<K, V> implements UnmodifiableMapPhase<K
             return common;
         }
 
-        final int size = map.size();
-        if (size == 1) {
+        if (map.size() == 1) {
             // Efficient single-entry implementation
             final Entry<K, V> e = map.entrySet().iterator().next();
             return SharedSingletonMap.unorderedOf(e.getKey(), e.getValue());
@@ -282,8 +282,8 @@ public abstract class ImmutableOffsetMap<K, V> implements UnmodifiableMapPhase<K
 
     @Override
     public final V get(final Object key) {
-        final Integer offset = offsets.get(key);
-        return offset == null ? null : objects[offset];
+        Integer offset;
+        return (offset = offsets.get(key)) == null ? null : objects[offset];
     }
 
     @Override
@@ -328,9 +328,7 @@ public abstract class ImmutableOffsetMap<K, V> implements UnmodifiableMapPhase<K
         final Iterator<K> it = offsets.keySet().iterator();
         int offset = 0;
         while (it.hasNext()) {
-            sb.append(it.next());
-            sb.append('=');
-            sb.append(objects[offset++]);
+            sb.append(it.next()).append('=').append(objects[offset++]);
 
             if (it.hasNext()) {
                 sb.append(", ");
@@ -352,7 +350,7 @@ public abstract class ImmutableOffsetMap<K, V> implements UnmodifiableMapPhase<K
         @Override
         public @NonNull Iterator<Entry<K, V>> iterator() {
             final Iterator<Entry<K, Integer>> it = offsets.entrySet().iterator();
-            return new UnmodifiableIterator<Entry<K, V>>() {
+            return new UnmodifiableIterator<>() {
                 @Override
                 public boolean hasNext() {
                     return it.hasNext();
@@ -395,6 +393,8 @@ public abstract class ImmutableOffsetMap<K, V> implements UnmodifiableMapPhase<K
         return f;
     }
 
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+            justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private static void setField(final @NonNull ImmutableOffsetMap<?, ?> map, final @NonNull Field field,
             final Object value) throws IOException {
         try {