*/
package org.opendaylight.yangtools.util;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.io.Serializable;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Map;
+import org.eclipse.jdt.annotation.NonNull;
/**
* Implementation of the {@link Map} interface which stores a single mapping. The key set is shared among all instances
}
@Override
- public ModifiableMapPhase<K, V> toModifiableMap() {
+ public @NonNull ModifiableMapPhase<K, V> toModifiableMap() {
return MutableOffsetMap.orderedCopyOf(this);
}
}
}
@Override
- public ModifiableMapPhase<K, V> toModifiableMap() {
+ public @NonNull ModifiableMapPhase<K, V> toModifiableMap() {
return MutableOffsetMap.unorderedCopyOf(this);
}
}
@SuppressWarnings("unchecked")
SharedSingletonMap(final K key, final V value) {
this.keySet = (SingletonSet<K>) CACHE.getUnchecked(key);
- this.value = Preconditions.checkNotNull(value);
+ this.value = requireNonNull(value);
}
public static <K, V> SharedSingletonMap<K, V> orderedOf(final K key, final V value) {
return new Unordered<>(key, value);
}
- public static <K, V> SharedSingletonMap<K, V> orderedCopyOf(final Map<K, V> m) {
- Preconditions.checkArgument(m.size() == 1);
+ public static <K, V> SharedSingletonMap<K, V> orderedCopyOf(final Map<K, V> map) {
+ checkArgument(map.size() == 1);
- final Entry<K, V> e = m.entrySet().iterator().next();
+ final Entry<K, V> e = map.entrySet().iterator().next();
return new Ordered<>(e.getKey(), e.getValue());
}
- public static <K, V> SharedSingletonMap<K, V> unorderedCopyOf(final Map<K, V> m) {
- Preconditions.checkArgument(m.size() == 1);
+ public static <K, V> SharedSingletonMap<K, V> unorderedCopyOf(final Map<K, V> map) {
+ checkArgument(map.size() == 1);
- final Entry<K, V> e = m.entrySet().iterator().next();
+ final Entry<K, V> e = map.entrySet().iterator().next();
return new Unordered<>(e.getKey(), e.getValue());
}
@Override
- public final SingletonSet<Entry<K, V>> entrySet() {
- return SingletonSet.<Entry<K, V>>of(new SimpleImmutableEntry<>(keySet.getElement(), value));
+ public final @NonNull SingletonSet<Entry<K, V>> entrySet() {
+ return SingletonSet.of(new SimpleImmutableEntry<>(keySet.getElement(), value));
}
@Override
- public final SingletonSet<K> keySet() {
+ public final @NonNull SingletonSet<K> keySet() {
return keySet;
}
@Override
- public final SingletonSet<V> values() {
+ public final @NonNull SingletonSet<V> values() {
return SingletonSet.of(value);
}
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public final boolean containsValue(final Object value) {
return this.value.equals(value);
}
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public final V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
}
@Override
+ @SuppressWarnings("checkstyle:parameterName")
public final void putAll(final Map<? extends K, ? extends V> m) {
throw new UnsupportedOperationException();
}