Package com.google.common.collect
Class EnumBiMap<K extends Enum<K>,V extends Enum<V>>
java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.collect.ForwardingMap<K,V>
com.google.common.collect.AbstractBiMap<K,V>
com.google.common.collect.EnumBiMap<K,V>
- All Implemented Interfaces:
BiMap<K,
,V> Serializable
,Map<K,
V>
A
BiMap
backed by two EnumMap
instances. Null keys and values are not permitted.
An EnumBiMap
and its inverse are both serializable.
See the Guava User Guide article on BiMap
.
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.collect.AbstractBiMap
AbstractBiMap.BiMapEntry, AbstractBiMap.Inverse<K,
V> Nested classes/interfaces inherited from class com.google.common.collect.ForwardingMap
ForwardingMap.StandardEntrySet, ForwardingMap.StandardKeySet, ForwardingMap.StandardValues
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
Fields inherited from class com.google.common.collect.AbstractBiMap
inverse
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) K
Returns its input, or throws an exception if this is not a valid key.(package private) V
checkValue
(V value) Returns its input, or throws an exception if this is not a valid value.Returns a new, emptyEnumBiMap
using the specified key and value types.Returns a new bimap with the same mappings as the specified map.inferKeyTypeOrObjectUnderJ2cl
(Map<K, ?> map) inferValueTypeOrObjectUnderJ2cl
(Map<?, V> map) keyType()
Returns the associated key type.private void
readObject
(ObjectInputStream stream) Returns the associated value type.private void
writeObject
(ObjectOutputStream stream) Methods inherited from class com.google.common.collect.AbstractBiMap
clear, containsValue, delegate, entrySet, entrySetIterator, forcePut, inverse, keySet, makeInverse, put, putAll, remove, replaceAll, setDelegates, setInverse, values
Methods inherited from class com.google.common.collect.ForwardingMap
containsKey, equals, get, hashCode, isEmpty, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString
Methods inherited from class com.google.common.collect.ForwardingObject
toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove, replace, replace, size
-
Field Details
-
keyTypeOrObjectUnderJ2cl
-
valueTypeOrObjectUnderJ2cl
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
EnumBiMap
-
-
Method Details
-
create
public static <K extends Enum<K>,V extends Enum<V>> EnumBiMap<K,V> create(Class<K> keyType, Class<V> valueType) Returns a new, emptyEnumBiMap
using the specified key and value types.- Parameters:
keyType
- the key typevalueType
- the value type
-
create
Returns a new bimap with the same mappings as the specified map. If the specified map is anEnumBiMap
, the new bimap has the same types as the provided map. Otherwise, the specified map must contain at least one mapping, in order to determine the key and value types.- Parameters:
map
- the map whose mappings are to be placed in this map- Throws:
IllegalArgumentException
- if map is not anEnumBiMap
instance and contains no mappings
-
inferKeyTypeOrObjectUnderJ2cl
-
inferValueTypeOrObjectUnderJ2cl
-
keyType
Returns the associated key type. -
valueType
Returns the associated value type. -
checkKey
Description copied from class:AbstractBiMap
Returns its input, or throws an exception if this is not a valid key. -
checkValue
Description copied from class:AbstractBiMap
Returns its input, or throws an exception if this is not a valid value.- Overrides:
checkValue
in classAbstractBiMap<K extends Enum<K>,
V extends Enum<V>>
-
writeObject
- Throws:
IOException
-
readObject
- Throws:
IOException
ClassNotFoundException
-