Top Description Fields Constructors Methods
com.google.common.collect

pack-priv final Class SingletonImmutableBiMap<K, V>

extends ImmutableBiMap<K, V>
Class Inheritance
Annotations
@GwtCompatible
serializable:true
emulated:true
@SuppressWarnings:serial
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull, com.google.common.collect.CollectPreconditions.checkEntryNotNull

Implementation of ImmutableMap with exactly one entry.
Authors
Jesse Wilson, Kevin Bourrillion

Field Summary

Modifier and TypeField and Description
private final transient ImmutableBiMap<V, K>
private transient ImmutableBiMap<V, K>
pack-priv final transient K
pack-priv final transient V

Constructor Summary

AccessConstructor and Description
pack-priv
SingletonImmutableBiMap(K singleKey, V singleValue)

private
SingletonImmutableBiMap(K singleKey, V singleValue, ImmutableBiMap<V, K> inverse)

Method Summary

Modifier and TypeMethod and Description
public boolean
containsKey(Object
key whose presence in this map is to be tested
key
)

Overrides com.google.common.collect.ImmutableMap.containsKey.

Implements java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.
public boolean
containsValue(Object
value whose presence in this map is to be tested
value
)

Overrides com.google.common.collect.ImmutableMap.containsValue.

Implements java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value.
pack-priv ImmutableSet<Map.Entry<K, V>>
pack-priv ImmutableSet<K>
public void
forEach(BiConsumer<? super K, ? super V>
The action to be performed for each entry
action
)

Overrides default java.util.Map.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.
public V
get(Object
the key whose associated value is to be returned
key
)

Implements abstract com.google.common.collect.ImmutableMap.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
public ImmutableBiMap<V, K>
inverse()

Implements abstract com.google.common.collect.ImmutableBiMap.inverse.

Implements com.google.common.collect.BiMap.inverse.

Returns the inverse view of this bimap, which maps each of this bimap's values to its associated key.
pack-priv boolean
public int
size()

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.
Inherited from com.google.common.collect.ImmutableBiMap:
builderbuilderWithExpectedSizecopyOfcopyOfcreateValuesforcePutofofofofofofofofofofofofEntriestoImmutableBiMapvalueswriteReplace

Field Detail

inverseback to summary
private final transient ImmutableBiMap<V, K> inverse
Annotations
@CheckForNull
lazyInverseback to summary
private transient ImmutableBiMap<V, K> lazyInverse
Annotations
@LazyInit
@RetainedWith
@CheckForNull
singleKeyback to summary
pack-priv final transient K singleKey
singleValueback to summary
pack-priv final transient V singleValue

Constructor Detail

SingletonImmutableBiMapback to summary
pack-priv SingletonImmutableBiMap(K singleKey, V singleValue)
SingletonImmutableBiMapback to summary
private SingletonImmutableBiMap(K singleKey, V singleValue, ImmutableBiMap<V, K> inverse)

Method Detail

containsKeyback to summary
public boolean containsKey(Object key)

Overrides com.google.common.collect.ImmutableMap.containsKey.

Implements java.util.Map.containsKey.

Doc from java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that Objects.equals(key, k). (There can be at most one such mapping.)

Parameters
key:Object

key whose presence in this map is to be tested

Returns:boolean

true if this map contains a mapping for the specified key

Annotations
@Override
containsValueback to summary
public boolean containsValue(Object value)

Overrides com.google.common.collect.ImmutableMap.containsValue.

Implements java.util.Map.containsValue.

Doc from java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that Objects.equals(value, v). This operation will probably require time linear in the map size for most implementations of the Map interface.

Parameters
value:Object

value whose presence in this map is to be tested

Returns:boolean

true if this map maps one or more keys to the specified value

Annotations
@Override
createEntrySetback to summary
pack-priv ImmutableSet<Map.Entry<K, V>> createEntrySet()

Implements abstract com.google.common.collect.ImmutableMap.createEntrySet.

Annotations
@Override
createKeySetback to summary
pack-priv ImmutableSet<K> createKeySet()

Implements abstract com.google.common.collect.ImmutableMap.createKeySet.

Annotations
@Override
forEachback to summary
public void forEach(BiConsumer<? super K, ? super V> action)

Overrides default java.util.Map.forEach.

Doc from java.util.Map.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of entry set iteration (if an iteration order is specified.) Exceptions thrown by the action are relayed to the caller.

Parameters
action:BiConsumer<? super K, ? super V>

The action to be performed for each entry

Annotations
@Override
getback to summary
public V get(Object key)

Implements abstract com.google.common.collect.ImmutableMap.get.

Implements java.util.Map.get.

Doc from java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
key:Object

the key whose associated value is to be returned

Returns:V

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override
@CheckForNull
inverseback to summary
public ImmutableBiMap<V, K> inverse()

Implements abstract com.google.common.collect.ImmutableBiMap.inverse.

Implements com.google.common.collect.BiMap.inverse.

Doc from com.google.common.collect.ImmutableBiMap.inverse.

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 another ImmutableBiMap.

Returns:ImmutableBiMap<V, K>

Doc from com.google.common.collect.BiMap.inverse.

the inverse view of this bimap

Annotations
@Override
isPartialViewback to summary
pack-priv boolean isPartialView()

Implements abstract com.google.common.collect.ImmutableMap.isPartialView.

Annotations
@Override
sizeback to summary
public int size()

Implements java.util.Map.size.

Doc from java.util.Map.size.

Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of key-value mappings in this map

Annotations
@Override