Class AbstractImmutableMultimap<K,​V,​C extends ImmutableCollection<V>>

    • Constructor Detail

      • AbstractImmutableMultimap

        protected AbstractImmutableMultimap​(MutableMap<K,​C> map)
        Creates a new multimap that clones the provided map into an ImmutableMap.
        Parameters:
        map - place to store the mapping from each key to its corresponding values
      • AbstractImmutableMultimap

        protected AbstractImmutableMultimap​(ImmutableMap<K,​C> immutableMap)
        Creates a new multimap that uses the provided immutableMap.
        Parameters:
        immutableMap - place to store the mapping from each key to its corresponding values
    • Method Detail

      • size

        public int size()
        Description copied from interface: Multimap
        Returns the number of key-value entry pairs.

        This method is implemented with O(1) (constant-time) performance.

        Specified by:
        size in interface Multimap<K,​V>
      • sizeDistinct

        public int sizeDistinct()
        Description copied from interface: Multimap
        Returns the number of distinct keys.
        Specified by:
        sizeDistinct in interface Multimap<K,​V>
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Multimap
        Returns true if there are no entries.
        Specified by:
        isEmpty in interface Multimap<K,​V>
      • get

        public C get​(K key)
        Description copied from interface: Multimap
        Returns a view of all values associated with the given key.

        If the given key does not exist, an empty RichIterable is returned.

        Specified by:
        get in interface ImmutableMultimap<K,​V>
        Specified by:
        get in interface Multimap<K,​V>
        Parameters:
        key - the key to search for
      • toMap

        public <R extends java.util.Collection<V>> MutableMap<K,​R> toMap​(Function0<R> collectionFactory)
        Description copied from interface: Multimap
        Returns a new MutableMap of keys from this Multimap to the mapped values as a RichIterable.
        Specified by:
        toMap in interface Multimap<K,​V>
        Parameters:
        collectionFactory - used to create the collections that hold the values and affects the return type
      • toImmutable

        public ImmutableMultimap<K,​V> toImmutable()
        Description copied from interface: Multimap
        Returns an immutable copy of this Multimap if it is not already immutable. If the Multimap is immutable, it will return itself.

        The returned Multimap will be Serializable if this Multimap is Serializable.

        Specified by:
        toImmutable in interface Multimap<K,​V>
      • readResolve

        protected java.lang.Object readResolve()
                                        throws java.io.ObjectStreamException
        Throws:
        java.io.ObjectStreamException