X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Futil%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Futil%2FImmutableOffsetMapTemplate.java;h=c171a82f7e62e5650a0bef8cc258809876c919d6;hb=c1d247ba667f38303e554bf8c4eda634d2d93b60;hp=091b40a4e8e95ec740b6ce52f933292bd6db14c1;hpb=972cf3c8946759e2a5d724cb3f6e2d2cd2b06b6d;p=yangtools.git diff --git a/common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableOffsetMapTemplate.java b/common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableOffsetMapTemplate.java index 091b40a4e8..c171a82f7e 100644 --- a/common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableOffsetMapTemplate.java +++ b/common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableOffsetMapTemplate.java @@ -12,6 +12,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableMap; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Arrays; import java.util.Collection; import java.util.Map; @@ -105,15 +106,20 @@ public abstract class ImmutableOffsetMapTemplate extends ImmutableMapTemplate final V[] objects = (V[]) new Object[size]; for (Entry entry : fromMap.entrySet()) { final K key = requireNonNull(entry.getKey()); - final Integer offset = offsets.get(key); - checkArgument(offset != null, "Key %s present in input, but not in offsets %s", key, offsets); - - objects[offset.intValue()] = transformValue(key, entry.getValue(), valueTransformer); + objects[offsetOf(key)] = transformValue(key, entry.getValue(), valueTransformer); } return createMap(offsets, objects); } + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", + justification = "SpotBugs does not grok checkArgument()") + private int offsetOf(final K key) { + final Integer offset = offsets.get(key); + checkArgument(offset != null, "Key %s present in input, but not in offsets %s", key, offsets); + return offset; + } + @Override @SafeVarargs public final @NonNull ImmutableOffsetMap instantiateWithValues(final V... values) {