Class StandardBiMap<K,​V>

  • All Implemented Interfaces:
    java.io.Serializable, java.util.Map<K,​V>

    public class StandardBiMap<K,​V>
    extends ForwardingMap<K,​V>
    implements java.io.Serializable
    A general-purpose bimap implementation using any two backing Map instances.
    Author:
    Kevin Bourrillion, Mike Bostock
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected StandardBiMap​(java.util.Map<K,​V> forward, java.util.Map<V,​K> backward)
      Package-private constructor for creating a map-backed bimap.
    • Constructor Detail

      • StandardBiMap

        protected StandardBiMap​(java.util.Map<K,​V> forward,
                                java.util.Map<V,​K> backward)
        Package-private constructor for creating a map-backed bimap.
    • Method Detail

      • setDelegates

        protected void setDelegates​(java.util.Map<K,​V> forward,
                                    java.util.Map<V,​K> backward)
        Specifies the delegate maps going in each direction. Called by the constructor and by subclasses during deserialization.
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
        Overrides:
        containsValue in class ForwardingMap<K,​V>
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class ForwardingMap<K,​V>
      • forcePut

        public V forcePut​(K key,
                          V value)
      • putInBothMaps

        protected V putInBothMaps​(K key,
                                  V value,
                                  boolean force)
      • updateInverseMap

        protected void updateInverseMap​(K key,
                                        boolean containedKey,
                                        V oldValue,
                                        V newValue)
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
        Overrides:
        remove in class ForwardingMap<K,​V>
      • removeFromBothMaps

        protected V removeFromBothMaps​(java.lang.Object key)
      • removeFromInverseMap

        protected void removeFromInverseMap​(V oldValue)
      • putAll

        public void putAll​(java.util.Map<? extends K,​? extends V> map)
        Specified by:
        putAll in interface java.util.Map<K,​V>
        Overrides:
        putAll in class ForwardingMap<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
        Overrides:
        clear in class ForwardingMap<K,​V>
      • keySet

        public java.util.Set<K> keySet()
        Specified by:
        keySet in interface java.util.Map<K,​V>
        Overrides:
        keySet in class ForwardingMap<K,​V>
      • values

        public java.util.Set<V> values()
        Specified by:
        values in interface java.util.Map<K,​V>
        Overrides:
        values in class ForwardingMap<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Overrides:
        entrySet in class ForwardingMap<K,​V>
      • checkState

        public static void checkState​(boolean expression)
      • checkState

        public static void checkState​(boolean expression,
                                      java.lang.Object errorMessage)
      • checkArgument

        public static void checkArgument​(boolean expression)
      • checkArgument

        public static void checkArgument​(boolean expression,
                                         java.lang.Object errorMessage)
      • checkArgument

        public static void checkArgument​(boolean expression,
                                         java.lang.String errorMessageTemplate,
                                         java.lang.Object... errorMessageArgs)