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

public final Class EnumHashBiMap<K extends java.lang.Enum<K>, V extends @Nullable Object>

extends AbstractBiMap<K extends Enum<K>, V extends @Nullable Object>
Class Inheritance
Annotations
@GwtCompatible
emulated:true
@J2ktIncompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

A BiMap backed by an EnumMap instance for keys-to-values, and a HashMap instance for values-to-keys. Null keys are not permitted, but null values are. An EnumHashBiMap and its inverse are both serializable.

See the Guava User Guide article on BiMap.

Author
Mike Bostock
Since
2.0

Field Summary

Modifier and TypeField and Description
pack-priv transient Class<K>
private static final long
Inherited from com.google.common.collect.AbstractBiMap:
inverse

Constructor Summary

AccessConstructor and Description
private
EnumHashBiMap(Class<K> keyType)

Method Summary

Modifier and TypeMethod and Description
pack-priv K
checkKey(K key)

Overrides com.google.common.collect.AbstractBiMap.checkKey.

Returns its input, or throws an exception if this is not a valid key.
public static <K extends Enum<K>, V extends @Nullable Object> EnumHashBiMap<K, V>
create(Class<K>
the key type
keyType
)

Returns a new, empty EnumHashBiMap using the specified key type.

public static <K extends Enum<K>, V extends @Nullable Object> EnumHashBiMap<K, V>
create(Map<K, ? extends V>
the map whose mappings are to be placed in this map
map
)

Constructs a new bimap with the same mappings as the specified map.

public V
forcePut(K
the key with which the specified value is to be associated
key
,
V
the value to be associated with the specified key
value
)

Overrides com.google.common.collect.AbstractBiMap.forcePut.

Implements com.google.common.collect.BiMap.forcePut.

An alternate form of put that silently removes any existing entry with the value value before proceeding with the put operation.
public Class<K>
keyType()

Returns the associated key type.

public V
put(K
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Overrides com.google.common.collect.AbstractBiMap.put.

Implements com.google.common.collect.BiMap.put, java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).
private void
private void
Inherited from com.google.common.collect.AbstractBiMap:
checkValueclearcontainsValuedelegateentrySetentrySetIteratorinversekeySetmakeInverseputAllremovereplaceAllsetDelegatessetInversevalues

Field Detail

keyTypeOrObjectUnderJ2clback to summary
pack-priv transient Class<K> keyTypeOrObjectUnderJ2cl
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.google.common.collect.AbstractBiMap.serialVersionUID.

Annotations
@GwtIncompatible

Constructor Detail

EnumHashBiMapback to summary
private EnumHashBiMap(Class<K> keyType)

Method Detail

checkKeyback to summary
pack-priv K checkKey(K key)

Overrides com.google.common.collect.AbstractBiMap.checkKey.

Doc from com.google.common.collect.AbstractBiMap.checkKey.

Returns its input, or throws an exception if this is not a valid key.

Annotations
@Override
createback to summary
public static <K extends Enum<K>, V extends @Nullable Object> EnumHashBiMap<K, V> create(Class<K> keyType)

Returns a new, empty EnumHashBiMap using the specified key type.

Parameters
keyType:Class<K>

the key type

createback to summary
public static <K extends Enum<K>, V extends @Nullable Object> EnumHashBiMap<K, V> create(Map<K, ? extends V> map)

Constructs a new bimap with the same mappings as the specified map. If the specified map is an EnumHashBiMap or an EnumBiMap, the new bimap has the same key type as the input bimap. Otherwise, the specified map must contain at least one mapping, in order to determine the key type.

Parameters
map:Map<K, ? extends V>

the map whose mappings are to be placed in this map

Exceptions
IllegalArgumentException:
if map is not an EnumBiMap or an EnumHashBiMap instance and contains no mappings
forcePutback to summary
public V forcePut(K key, V value)

Overrides com.google.common.collect.AbstractBiMap.forcePut.

Implements com.google.common.collect.BiMap.forcePut.

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

An alternate form of put that silently removes any existing entry with the value value before proceeding with the put operation. If the bimap previously contained the provided key-value mapping, this method has no effect.

Note that a successful call to this method could cause the size of the bimap to increase by one, stay the same, or even decrease by one.

Warning

If an existing entry with this value is removed, the key for that entry is discarded and not returned.

Parameters
key:K

the key with which the specified value is to be associated

value:V

the value to be associated with the specified key

Returns:V

the value that was previously associated with the key, or null if there was no previous entry. (If the bimap contains null values, then forcePut, like put, returns null both if the key is absent and if it is present with a null value.)

Annotations
@CanIgnoreReturnValue
@Override
@SuppressWarnings:RedundantOverride
@CheckForNull
keyTypeback to summary
public Class<K> keyType()

Returns the associated key type.

Annotations
@GwtIncompatible
putback to summary
public V put(K key, V value)

Overrides com.google.common.collect.AbstractBiMap.put.

Implements com.google.common.collect.BiMap.put, java.util.Map.put.

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

Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

Parameters
key:K

Doc from java.util.Map.put.

key with which the specified value is to be associated

value:V

Doc from java.util.Map.put.

value to be associated with the specified key

Returns:V

Doc from java.util.Map.put.

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)

Annotations
@CanIgnoreReturnValue
@Override
@SuppressWarnings:RedundantOverride
@CheckForNull
readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
Annotations
@SuppressWarnings:unchecked
@GwtIncompatible
writeObjectback to summary
private void writeObject(ObjectOutputStream stream) throws IOException
Annotations
@GwtIncompatible
Serial data
the key class, number of entries, first key, first value, second key, second value, and so on.