Class AbstractMultiValuedMap.WrappedCollection

  • All Implemented Interfaces:
    java.lang.Iterable<V>, java.util.Collection<V>
    Direct Known Subclasses:
    AbstractListValuedMap.WrappedList, AbstractSetValuedMap.WrappedSet
    Enclosing class:
    AbstractMultiValuedMap<K,​V>

    class AbstractMultiValuedMap.WrappedCollection
    extends java.lang.Object
    implements java.util.Collection<V>
    Wrapped collection to handle add and remove on the collection returned by get(object).

    Currently, the wrapped collection is not cached and has to be retrieved from the underlying map. This is safe, but not very efficient and should be improved in subsequent releases. For this purpose, the scope of this collection is set to package private to simplify later refactoring.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected K key  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(V value)  
      boolean addAll​(java.util.Collection<? extends V> other)  
      void clear()  
      boolean contains​(java.lang.Object obj)  
      boolean containsAll​(java.util.Collection<?> other)  
      protected java.util.Collection<V> getMapping()  
      boolean isEmpty()  
      java.util.Iterator<V> iterator()  
      boolean remove​(java.lang.Object item)  
      boolean removeAll​(java.util.Collection<?> c)  
      boolean retainAll​(java.util.Collection<?> c)  
      int size()  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] a)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        equals, hashCode, parallelStream, removeIf, spliterator, stream
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Field Detail

      • key

        protected final K key
    • Constructor Detail

      • WrappedCollection

        public WrappedCollection​(K key)
    • Method Detail

      • getMapping

        protected java.util.Collection<V> getMapping()
      • add

        public boolean add​(V value)
        Specified by:
        add in interface java.util.Collection<V>
      • addAll

        public boolean addAll​(java.util.Collection<? extends V> other)
        Specified by:
        addAll in interface java.util.Collection<V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<V>
      • iterator

        public java.util.Iterator<V> iterator()
        Specified by:
        iterator in interface java.util.Collection<V>
        Specified by:
        iterator in interface java.lang.Iterable<V>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<V>
      • contains

        public boolean contains​(java.lang.Object obj)
        Specified by:
        contains in interface java.util.Collection<V>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> other)
        Specified by:
        containsAll in interface java.util.Collection<V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<V>
      • remove

        public boolean remove​(java.lang.Object item)
        Specified by:
        remove in interface java.util.Collection<V>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<V>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<V>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<V>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<V>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object