Package com.google.common.collect
Class SingletonImmutableBiMap<K,V>
- java.lang.Object
-
- com.google.common.collect.ImmutableMap<K,V>
-
- com.google.common.collect.ImmutableBiMapFauxverideShim<K,V>
-
- com.google.common.collect.ImmutableBiMap<K,V>
-
- com.google.common.collect.SingletonImmutableBiMap<K,V>
-
- All Implemented Interfaces:
BiMap<K,V>
,java.io.Serializable
,java.util.Map<K,V>
final class SingletonImmutableBiMap<K,V> extends ImmutableBiMap<K,V>
Implementation ofImmutableMap
with exactly one entry.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableBiMap
ImmutableBiMap.Builder<K,V>
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableMap
ImmutableMap.IteratorBasedImmutableMap<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description private ImmutableBiMap<V,K>
inverse
private ImmutableBiMap<V,K>
lazyInverse
(package private) K
singleKey
(package private) V
singleValue
-
Fields inherited from class com.google.common.collect.ImmutableMap
EMPTY_ENTRY_ARRAY
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
SingletonImmutableBiMap(K singleKey, V singleValue)
private
SingletonImmutableBiMap(K singleKey, V singleValue, ImmutableBiMap<V,K> inverse)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
(package private) ImmutableSet<java.util.Map.Entry<K,V>>
createEntrySet()
(package private) ImmutableSet<K>
createKeySet()
void
forEach(java.util.function.BiConsumer<? super K,? super V> action)
V
get(java.lang.Object key)
ImmutableBiMap<V,K>
inverse()
Returns the inverse view of this bimap, which maps each of this bimap's values to its associated key.(package private) boolean
isPartialView()
int
size()
-
Methods inherited from class com.google.common.collect.ImmutableBiMap
builder, builderWithExpectedSize, copyOf, copyOf, createValues, forcePut, of, of, of, of, of, of, of, of, of, of, of, ofEntries, toImmutableBiMap, values, writeReplace
-
Methods inherited from class com.google.common.collect.ImmutableBiMapFauxverideShim
toImmutableMap, toImmutableMap
-
Methods inherited from class com.google.common.collect.ImmutableMap
asMultimap, checkNoConflict, clear, compute, computeIfAbsent, computeIfPresent, conflictException, entryOf, entrySet, equals, getOrDefault, hashCode, isEmpty, isHashCodeFast, keyIterator, keySet, keySpliterator, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, toString
-
-
-
-
Field Detail
-
singleKey
final transient K singleKey
-
singleValue
final transient V singleValue
-
inverse
@CheckForNull private final transient ImmutableBiMap<V,K> inverse
-
lazyInverse
@CheckForNull private transient ImmutableBiMap<V,K> lazyInverse
-
-
Method Detail
-
get
@CheckForNull public V get(@CheckForNull java.lang.Object key)
-
size
public int size()
-
containsKey
public boolean containsKey(@CheckForNull java.lang.Object key)
- Specified by:
containsKey
in interfacejava.util.Map<K,V>
- Overrides:
containsKey
in classImmutableMap<K,V>
-
containsValue
public boolean containsValue(@CheckForNull java.lang.Object value)
- Specified by:
containsValue
in interfacejava.util.Map<K,V>
- Overrides:
containsValue
in classImmutableMap<K,V>
-
isPartialView
boolean isPartialView()
- Specified by:
isPartialView
in classImmutableMap<K,V>
-
createEntrySet
ImmutableSet<java.util.Map.Entry<K,V>> createEntrySet()
- Specified by:
createEntrySet
in classImmutableMap<K,V>
-
createKeySet
ImmutableSet<K> createKeySet()
- Specified by:
createKeySet
in classImmutableMap<K,V>
-
inverse
public ImmutableBiMap<V,K> inverse()
Description copied from class:ImmutableBiMap
Returns the inverse view of this bimap, which maps each of this bimap's values to its associated key. The two bimaps are backed by the same data; any changes to one will appear in the other.Note:There is no guaranteed correspondence between the iteration order of a bimap and that of its inverse.
The inverse of an
ImmutableBiMap
is anotherImmutableBiMap
.
-
-