Interface SymmetricMap<K,​V>

    • Method Detail

      • getKey

        Optional<K> getKey​(Object value)
        Returns the key associated with the given value, or empty if not found.
        Parameters:
        value - the value to look up
        Returns:
        an Optional containing the key associated with value, or empty if not found
      • safePut

        void safePut​(K key,
                     V value)
        Associates the given key with the given value, throwing an exception if the key or value already exists in this map.

        Use Map.put(Object, Object) for a permissive insertion that silently removes conflicting entries.

        Parameters:
        key - the key
        value - the value
        Throws:
        IllegalArgumentException - if the key or value already exists
      • removeByValue

        Optional<K> removeByValue​(Object value)
        Removes the entry associated with the given value, if present. Symmetric to Map.remove(Object) which removes by key.
        Parameters:
        value - the value whose entry is to be removed
        Returns:
        an Optional containing the key that was associated with value, or empty if not found
      • values

        Set<V> values()
        Returns a Set view of the values contained in this map.

        This method narrows the return type of Map.values() from Collection to Set, which is valid since values in a bijective map are unique by definition.

        The returned set is a live view of the map: changes to the map are reflected in the set, and vice versa.

        Specified by:
        values in interface Map<K,​V>
        Returns:
        a set view of the values contained in this map