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 longFields inherited from class com.google.common.collect.AbstractBiMap
inverse -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) KReturns its input, or throws an exception if this is not a valid key.(package private) VcheckValue(V value) Returns its input, or throws an exception if this is not a valid value.Returns a new, emptyEnumBiMapusing the specified key and value types.Returns a new bimap with the same mappings as the specified map.inferKeyType(Map<K, ?> map) inferValueType(Map<?, V> map) keyType()Returns the associated key type.private voidreadObject(ObjectInputStream stream) Returns the associated value type.private voidwriteObject(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, valuesMethods inherited from class com.google.common.collect.ForwardingMap
containsKey, equals, get, hashCode, isEmpty, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToStringMethods inherited from class com.google.common.collect.ForwardingObject
toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove, replace, replace, size
-
Field Details
-
keyType
-
valueType
-
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, emptyEnumBiMapusing 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 anEnumBiMapinstance and contains no mappings
-
inferKeyType
-
inferValueType
-
keyType
Returns the associated key type. -
valueType
Returns the associated value type. -
checkKey
Description copied from class:AbstractBiMapReturns its input, or throws an exception if this is not a valid key. -
checkValue
Description copied from class:AbstractBiMapReturns its input, or throws an exception if this is not a valid value.- Overrides:
checkValuein classAbstractBiMap<K extends Enum<K>,V extends Enum<V>>
-
writeObject
- Throws:
IOException
-
readObject
- Throws:
IOExceptionClassNotFoundException
-