Class UnmodifiableMultimap<A,B>

java.lang.Object
java.util.AbstractCollection<Map.Entry<A,B>>
eu.bandm.tools.ops.UnmodifiableMultimap<A,B>
All Implemented Interfaces:
Multimap<A,B>, Iterable<Map.Entry<A,B>>, Collection<Map.Entry<A,B>>, BiPredicate<A,B>, Set<Map.Entry<A,B>>

abstract class UnmodifiableMultimap<A,B> extends AbstractCollection<Map.Entry<A,B>> implements Multimap<A,B>
A wrapper to protect the contents of an instance of Multimap.
  • Constructor Details

    • UnmodifiableMultimap

      UnmodifiableMultimap()
  • Method Details

    • test

      public boolean test(A a, B b)
      Specified by:
      test in interface BiPredicate<A,B>
    • add

      public final boolean add(A a, B b)
      Description copied from interface: Multimap
      Adds a pair to this multimap. This operation must be stable: adding a pair that equals any pair contained in this multimap componentwise must not change this multimap.
      Specified by:
      add in interface Multimap<A,B>
      Parameters:
      a - the left component of the pair to add.
      b - the right component of the pair to add.
      Returns:
      true if this multimap has been changed by this operation, false otherwise.
    • contains

      public final boolean contains(A a, B b)
      Description copied from interface: Multimap
      Whether this multimap contains a pair with the given components.
      Specified by:
      contains in interface Multimap<A,B>
      Parameters:
      a - the left component of the pair to add.
      b - the right component of the pair to add.
    • remove

      public final boolean remove(A a, B b)
      Description copied from interface: Multimap
      Removes a pair from this this multimap. Removing a pair that equals no pair contained in this multimap componentwise must not change this multimap.
      Specified by:
      remove in interface Multimap<A,B>
      Parameters:
      a - the left component of the pair to remove.
      b - the right component of the pair to remove.
      Returns:
      true if this multimap has been changed by this operation, false otherwise.
    • removeUnchecked

      public final boolean removeUnchecked(Object a, Object b)
      Specified by:
      removeUnchecked in interface Multimap<A,B>
    • removeDomain

      public final boolean removeDomain(A a)
      Description copied from interface: Multimap
      Removes all pairs with a given left component from this multimap. The effect of the implementation on this multimap must be equivalent to the following code:
       removeDomain(final A a) {
         for (B b : new HashSet<B>(range())) remove(a, b) ;
       }
       
      Specified by:
      removeDomain in interface Multimap<A,B>
      Parameters:
      a - the left component of all pairs to remove.
      Returns:
      true if this multimap has been changed by this operation, false otherwise.
    • removeDomainUnchecked

      public final boolean removeDomainUnchecked(Object a)
    • removeRange

      public final boolean removeRange(B b)
      Description copied from interface: Multimap
      Removes all pairs with a given right component from this multimap. The effect of the implementation on this multimap must be equivalent to the following code:
       removeRange(final B b) {
         for (A a : new HashSet<A>(domain())) remove(a, b) ;
       }
       
      Specified by:
      removeRange in interface Multimap<A,B>
      Parameters:
      b - the right component of all pairs to remove.
      Returns:
      true if this multimap has been changed by this operation, false otherwise.
    • removeRangeUnchecked

      public final boolean removeRangeUnchecked(Object b)
    • removeAllDomain

      public final boolean removeAllDomain(Collection<? extends A> a)
      Description copied from interface: Multimap
      Removes all pairs with a left component in the given collection from this multimap.
      Specified by:
      removeAllDomain in interface Multimap<A,B>
    • removeAllDomainUnchecked

      public final boolean removeAllDomainUnchecked(Collection<?> a)
      Specified by:
      removeAllDomainUnchecked in interface Multimap<A,B>
      See Also:
    • retainAllDomain

      public final boolean retainAllDomain(Collection<? extends A> a)
      Description copied from interface: Multimap
      Removes all pairs with a left component which is not the given collection from this multimap.
      Specified by:
      retainAllDomain in interface Multimap<A,B>
    • retainAllDomainUnchecked

      public final boolean retainAllDomainUnchecked(Collection<?> a)
      Specified by:
      retainAllDomainUnchecked in interface Multimap<A,B>
      See Also:
    • removeAllRange

      public final boolean removeAllRange(Collection<? extends B> b)
      Description copied from interface: Multimap
      Removes all pairs with a right component in the given collection from this multimap.
      Specified by:
      removeAllRange in interface Multimap<A,B>
    • removeAllRangeUnchecked

      public final boolean removeAllRangeUnchecked(Collection<?> b)
      Specified by:
      removeAllRangeUnchecked in interface Multimap<A,B>
      See Also:
    • retainAllRange

      public final boolean retainAllRange(Collection<? extends B> b)
      Description copied from interface: Multimap
      Removes all pairs with a right component which is not the given collection from this multimap.
      Specified by:
      retainAllRange in interface Multimap<A,B>
    • retainAllRangeUnchecked

      public final boolean retainAllRangeUnchecked(Collection<?> b)
      Specified by:
      retainAllRangeUnchecked in interface Multimap<A,B>
      See Also:
    • image

      public Set<B> image(A a)
      Description copied from interface: Multimap
      Returns the set of right components of pairs with a given left component in this multimap.

      The returned set need not be modifiable. The behaviour of this multimap after successfully modifying the returned set is unspecified.

      Specified by:
      image in interface Multimap<A,B>
      Parameters:
      a - a left component.
      Returns:
      the set of right components of pairs with a left component that equals(a) in this multimap.
    • imageAll

      public Set<B> imageAll(Collection<? extends A> c)
      Description copied from interface: Multimap
      Returns the set of right components of pairs in this multimap, which have a left component in the given set.
      Specified by:
      imageAll in interface Multimap<A,B>
    • imageMap

      public Map<A,Set<B>> imageMap()
      Description copied from interface: Multimap
      Returns a map which maps each A which appears as a left component to a set of all B which appear as its right component.
      Specified by:
      imageMap in interface Multimap<A,B>
    • preimage

      public Set<A> preimage(B b)
      Description copied from interface: Multimap
      Returns the set of left components of pairs with a given right component in this multimap.

      The returned set need not be modifiable. The behaviour of this multimap after successfully modifying the returned set is unspecified.

      Specified by:
      preimage in interface Multimap<A,B>
      Parameters:
      b - a right component.
      Returns:
      the set of left components of pairs with a right component that equals(b) in this multimap.
    • preimageAll

      public Set<A> preimageAll(Collection<? extends B> c)
      Description copied from interface: Multimap
      Returns the set of left components of pairs in this multimap, which have a right component in the given set.
      Specified by:
      preimageAll in interface Multimap<A,B>
    • preimageMap

      public Map<B,Set<A>> preimageMap()
      Description copied from interface: Multimap
      Returns a map which maps each B which appears as a right component to a set of all A which appear as its left component.
      Specified by:
      preimageMap in interface Multimap<A,B>