public final class EnumHashBiMap<K extends java.lang.Enum<K>,V> extends AbstractBiMap<K,V>
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.
AbstractBiMap.BiMapEntry, AbstractBiMap.Inverse<K,V>ForwardingMap.StandardEntrySet, ForwardingMap.StandardKeySet, ForwardingMap.StandardValues| Modifier and Type | Field and Description |
|---|---|
private java.lang.Class<K> |
keyType |
private static long |
serialVersionUID |
inverse| Modifier | Constructor and Description |
|---|---|
private |
EnumHashBiMap(java.lang.Class<K> keyType) |
| Modifier and Type | Method and Description |
|---|---|
(package private) K |
checkKey(K key)
Returns its input, or throws an exception if this is not a valid key.
|
static <K extends java.lang.Enum<K>,V> |
create(java.lang.Class<K> keyType)
Returns a new, empty
EnumHashBiMap using the specified key type. |
static <K extends java.lang.Enum<K>,V> |
create(java.util.Map<K,? extends V> map)
Constructs a new bimap with the same mappings as the specified map.
|
V |
forcePut(K key,
V value)
An alternate form of
put that silently removes any existing entry with the value value before proceeding with the BiMap.put(K, V) operation. |
java.lang.Class<K> |
keyType()
Returns the associated key type.
|
V |
put(K key,
V value) |
private void |
readObject(java.io.ObjectInputStream stream) |
private void |
writeObject(java.io.ObjectOutputStream stream) |
checkValue, clear, containsValue, delegate, entrySet, entrySetIterator, inverse, keySet, makeInverse, putAll, remove, replaceAll, setDelegates, setInverse, valuescontainsKey, equals, get, hashCode, isEmpty, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToStringtoStringprivate static final long serialVersionUID
private EnumHashBiMap(java.lang.Class<K> keyType)
public static <K extends java.lang.Enum<K>,V> EnumHashBiMap<K,V> create(java.lang.Class<K> keyType)
EnumHashBiMap using the specified key type.keyType - the key typepublic static <K extends java.lang.Enum<K>,V> EnumHashBiMap<K,V> create(java.util.Map<K,? extends V> map)
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.map - the map whose mappings are to be placed in this mapjava.lang.IllegalArgumentException - if map is not an EnumBiMap or an EnumHashBiMap
instance and contains no mappingsK checkKey(K key)
AbstractBiMapcheckKey in class AbstractBiMap<K extends java.lang.Enum<K>,V>@CheckForNull public V forcePut(K key, V value)
BiMapput that silently removes any existing entry with the value value before proceeding with the BiMap.put(K, V) 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.
forcePut in interface BiMap<K extends java.lang.Enum<K>,V>forcePut in class AbstractBiMap<K extends java.lang.Enum<K>,V>key - the key with which the specified value is to be associatedvalue - the value to be associated with the specified keynull 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.)public java.lang.Class<K> keyType()
private void writeObject(java.io.ObjectOutputStream stream)
throws java.io.IOException
java.io.IOExceptionprivate void readObject(java.io.ObjectInputStream stream)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.ClassNotFoundException