Class UnmodifiableMultiset<A>

java.lang.Object
eu.bandm.tools.util.multi.UnmodifiableMultiset<A>
Type Parameters:
A - type of the contained elements
All Implemented Interfaces:
Multiset<A>, Serializable, Iterable<A>

abstract class UnmodifiableMultiset<A> extends Object implements Multiset<A>
A wrapper to protect the contents of an instance of a multiset. Not to be called by the user, but by the factory methods in Multisets. To create such a wrapper, use Multisets.unmodifiableMultiset(eu.bandm.tools.util.multi.Multiset<A>). All methods which try to change the state of this instance throw an UnsupportedOperationException.
  • Constructor Details

    • UnmodifiableMultiset

      public UnmodifiableMultiset()
      Only constructor
  • Method Details

    • clear

      public void clear()
      Remove all objects from this instance.
      Specified by:
      clear in interface Multiset<A>
      Throws:
      UnsupportedOperationException - always
    • add

      public boolean add(A a)
      Add one element once to this set. This means to increase the number of contained elements by one.
      Specified by:
      add in interface Multiset<A>
      Parameters:
      a - element to add.
      Returns:
      whether the Multiset has been changed. Is defined only for a better analogy to the philosophy of java.util.Collection, but indeed returns always true.
      Throws:
      UnsupportedOperationException - always
    • add

      public boolean add(A a, int i)
      Add one element multiple times to this set. This means to increase the number of contained elements by the given mulitplicity.
      Specified by:
      add in interface Multiset<A>
      Parameters:
      a - element to add.
      i - number of additions. Must be greater or equal to zero.
      Returns:
      whether the Multiset has been changed. This is the case when i is greater zero.
      Throws:
      UnsupportedOperationException - always
    • remove

      public boolean remove(A a)
      Remove the given element once from this set. That means, decrement the number of its containments if and only if it is greater than zero.
      Specified by:
      remove in interface Multiset<A>
      Parameters:
      a - element to remove.
      Returns:
      whether this instance has changed.
      Throws:
      UnsupportedOperationException - always
    • removeUnchecked

      public boolean removeUnchecked(Object a)
      Remove the given element once from this set. That means, decrement the number of its containments iff it is greater zero.
      Specified by:
      removeUnchecked in interface Multiset<A>
      Parameters:
      a - element to remove.
      Returns:
      whether this instance has changed.
      Throws:
      UnsupportedOperationException - always
    • removeDomain

      public boolean removeDomain(A a)
      Remove the given element completely from this set.
      Specified by:
      removeDomain in interface Multiset<A>
      Parameters:
      a - element to remove.
      Returns:
      whether this instance has changed.
      Throws:
      UnsupportedOperationException - always
    • removeDomainUnchecked

      public boolean removeDomainUnchecked(Object a)
      Remove the given element completely from this set.
      Specified by:
      removeDomainUnchecked in interface Multiset<A>
      Parameters:
      a - element to remove.
      Returns:
      whether this instance has changed.
      Throws:
      UnsupportedOperationException - always
    • removeAll

      public boolean removeAll(Collection<? extends A> c)
      Remove all elements in the given collection completely from this set.
      Specified by:
      removeAll in interface Multiset<A>
      Parameters:
      c - collection of all elements to remove
      Returns:
      whether this instance has changed
      Throws:
      UnsupportedOperationException - always
    • removeAllUnchecked

      public boolean removeAllUnchecked(Collection<?> c)
      Remove all elements in the given collection completely from this set.
      Specified by:
      removeAllUnchecked in interface Multiset<A>
      Parameters:
      c - collection of all elements to remove
      Returns:
      whether this instance has changed
      Throws:
      UnsupportedOperationException - always
    • retainAll

      public boolean retainAll(Collection<? extends A> c)
      Remove all elements not contained in the given collection completely from this set.
      Specified by:
      retainAll in interface Multiset<A>
      Parameters:
      c - collection of all elements not to remove
      Returns:
      whether this instance has changed
      Throws:
      UnsupportedOperationException - always
    • retainAllUnchecked

      public boolean retainAllUnchecked(Collection<?> c)
      Remove all elements not contained in the given collection completely from this set.
      Specified by:
      retainAllUnchecked in interface Multiset<A>
      Parameters:
      c - collection of all elements not to remove
      Returns:
      whether this instance has changed
      Throws:
      UnsupportedOperationException - always