Interface ReverseMap<K,​V>

  • Type Parameters:
    K - The type of map key.
    V - The type of map value.
    All Superinterfaces:
    java.util.Map<K,​V>
    All Known Subinterfaces:
    ReadWriteLockReverseMap<K,​V>
    All Known Implementing Classes:
    DecoratorReadWriteLockReverseMap, DecoratorReverseMap

    public interface ReverseMap<K,​V>
    extends java.util.Map<K,​V>
    A map that also allows lookup of the map keys keyed to the values.

    The keys and values in this map have a one-to-one relationship. Associating multiple values with a key will likely result in errant functionality.

    Author:
    Garret Wilson
    • 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>
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      K getKey​(V value)
      Returns the key that represents the given value.
      K removeValue​(V value)
      Removes the mapping for a value from this map if it is present.
      • Methods inherited from interface java.util.Map

        clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
    • Method Detail

      • getKey

        K getKey​(V value)
        Returns the key that represents the given value.
        Parameters:
        value - The value whose associated key is to be returned.
        Returns:
        The key to which this map reverse maps the specified value, or null if the map contains no reverse mapping for this value.
        Throws:
        java.lang.ClassCastException - Thrown if the value is of an inappropriate type for this map (optional).
        java.lang.NullPointerException - Thrown if the value is null and this map does not not permit null values (optional).
        See Also:
        Map.containsValue(Object)
      • removeValue

        K removeValue​(V value)
        Removes the mapping for a value from this map if it is present.
        Parameters:
        value - The value whose mapping is to be removed from the map.
        Returns:
        The previous key associated with the value, or null if there was no mapping for the value.
        Throws:
        java.lang.UnsupportedOperationException - if the remove operation is not supported by this map
        java.lang.ClassCastException - if the value is of an inappropriate type for this map (optional).
        java.lang.NullPointerException - if the specified value is null and this map does not permit null values (optional).