public final class EnumBiMap<K extends java.lang.Enum<K>,V extends java.lang.Enum<V>> extends AbstractBiMap<K,V>
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.
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 |
private java.lang.Class<V> |
valueType |
inverse| Modifier | Constructor and Description |
|---|---|
private |
EnumBiMap(java.lang.Class<K> keyType,
java.lang.Class<V> valueType) |
| 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.
|
(package private) V |
checkValue(V value)
Returns its input, or throws an exception if this is not a valid value.
|
static <K extends java.lang.Enum<K>,V extends java.lang.Enum<V>> |
create(java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Returns a new, empty
EnumBiMap using the specified key and value types. |
static <K extends java.lang.Enum<K>,V extends java.lang.Enum<V>> |
create(java.util.Map<K,V> map)
Returns a new bimap with the same mappings as the specified map.
|
(package private) static <K extends java.lang.Enum<K>> |
inferKeyType(java.util.Map<K,?> map) |
private static <V extends java.lang.Enum<V>> |
inferValueType(java.util.Map<?,V> map) |
java.lang.Class<K> |
keyType()
Returns the associated key type.
|
private void |
readObject(java.io.ObjectInputStream stream) |
java.lang.Class<V> |
valueType()
Returns the associated value type.
|
private void |
writeObject(java.io.ObjectOutputStream stream) |
clear, containsValue, delegate, entrySet, entrySetIterator, forcePut, inverse, keySet, makeInverse, put, putAll, remove, replaceAll, setDelegates, setInverse, valuescontainsKey, equals, get, hashCode, isEmpty, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToStringtoStringprivate static final long serialVersionUID
public static <K extends java.lang.Enum<K>,V extends java.lang.Enum<V>> EnumBiMap<K,V> create(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
EnumBiMap using the specified key and value types.keyType - the key typevalueType - the value typepublic static <K extends java.lang.Enum<K>,V extends java.lang.Enum<V>> EnumBiMap<K,V> create(java.util.Map<K,V> map)
EnumBiMap, 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.map - the map whose mappings are to be placed in this mapjava.lang.IllegalArgumentException - if map is not an EnumBiMap instance and contains no
mappingsstatic <K extends java.lang.Enum<K>> java.lang.Class<K> inferKeyType(java.util.Map<K,?> map)
private static <V extends java.lang.Enum<V>> java.lang.Class<V> inferValueType(java.util.Map<?,V> map)
public java.lang.Class<K> keyType()
public java.lang.Class<V> valueType()
K checkKey(K key)
AbstractBiMapV checkValue(V value)
AbstractBiMapcheckValue in class AbstractBiMap<K extends java.lang.Enum<K>,V extends java.lang.Enum<V>>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