Make dynamic maps return empty immutable collections instead of throwing
This commit is contained in:
parent
6fa3e64210
commit
03e7df5308
|
|
@ -2,8 +2,11 @@ package org.embeddedt.modernfix.util;
|
|||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSets;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectCollection;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectLists;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectSets;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
|
@ -15,17 +18,17 @@ public class DynamicInt2ObjectMap<V> extends DynamicMap<Integer, V> implements I
|
|||
|
||||
@Override
|
||||
public IntSet keySet() {
|
||||
throw new UnsupportedOperationException();
|
||||
return IntSets.EMPTY_SET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectCollection<V> values() {
|
||||
throw new UnsupportedOperationException();
|
||||
return ObjectLists.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectSet<Map.Entry<Integer, V>> entrySet() {
|
||||
throw new UnsupportedOperationException();
|
||||
return ObjectSets.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
|
@ -64,18 +65,18 @@ public class DynamicMap<K, V> implements Map<K, V> {
|
|||
@NotNull
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
throw new UnsupportedOperationException();
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
throw new UnsupportedOperationException();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<Entry<K, V>> entrySet() {
|
||||
throw new UnsupportedOperationException();
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user