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;
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());
@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
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(", ");
@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();
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 {