Class UnmodifiableMultiSet<E>
java.lang.Object
org.apache.commons.collections4.collection.AbstractCollectionDecorator<E>
org.apache.commons.collections4.multiset.AbstractMultiSetDecorator<E>
org.apache.commons.collections4.multiset.UnmodifiableMultiSet<E>
- Type Parameters:
E- The type held in the multiset
- All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, MultiSet<E>, Unmodifiable
public final class UnmodifiableMultiSet<E>
extends AbstractMultiSetDecorator<E>
implements Unmodifiable
Decorates another
MultiSet to ensure it can't be altered.
Attempts to modify it will result in an UnsupportedOperationException.
- Since:
- 4.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface MultiSet
MultiSet.Entry<E> -
Method Summary
Modifier and TypeMethodDescriptionbooleanAlways throwsUnsupportedOperationException.intAlways throwsUnsupportedOperationException.booleanaddAll(Collection<? extends E> coll) Always throwsUnsupportedOperationException.voidclear()Always throwsUnsupportedOperationException.entrySet()Returns aSetof all entries contained in the MultiSet.iterator()Returns anIteratorover the entire set of members, including copies due to cardinality.booleanAlways throwsUnsupportedOperationException.intAlways throwsUnsupportedOperationException.booleanremoveAll(Collection<?> coll) Always throwsUnsupportedOperationException.booleanAlways throwsUnsupportedOperationException.booleanretainAll(Collection<?> coll) Always throwsUnsupportedOperationException.intAlways throwsUnsupportedOperationException.Returns aSetof unique elements in the MultiSet.static <E> MultiSet<E> unmodifiableMultiSet(MultiSet<? extends E> multiset) Factory method to create an unmodifiable multiset.Methods inherited from class AbstractMultiSetDecorator
decorated, equals, getCount, hashCodeMethods inherited from class AbstractCollectionDecorator
contains, containsAll, isEmpty, setCollection, size, toArray, toArray, toStringMethods inherited from interface Collection
contains, isEmpty, parallelStream, spliterator, stream, toArray, toArrayMethods inherited from interface MultiSet
containsAll, size
-
Method Details
-
unmodifiableMultiSet
Factory method to create an unmodifiable multiset.If the multiset passed in is already unmodifiable, it is returned.
- Type Parameters:
E- the type of the elements in the multiset- Parameters:
multiset- The multiset to decorate, may not be null- Returns:
- An unmodifiable MultiSet
- Throws:
NullPointerException- if multiset is null
-
add
Always throwsUnsupportedOperationException.- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceMultiSet<E>- Overrides:
addin classAbstractCollectionDecorator<E>- Parameters:
object- Ignored.- Returns:
truealways, as the size of the MultiSet is increased in any case.- Throws:
UnsupportedOperationException- Always thrown.
-
add
Always throwsUnsupportedOperationException.- Specified by:
addin interfaceMultiSet<E>- Overrides:
addin classAbstractMultiSetDecorator<E>- Parameters:
object- Ignored.count- Ignored.- Returns:
- The number of occurrences of the object in the multiset before this operation; possibly zero.
- Throws:
UnsupportedOperationException- Always thrown.
-
addAll
Always throwsUnsupportedOperationException.- Specified by:
addAllin interfaceCollection<E>- Overrides:
addAllin classAbstractCollectionDecorator<E>- Parameters:
coll- Ignored.- Throws:
UnsupportedOperationException- Always thrown.
-
clear
Always throwsUnsupportedOperationException.- Specified by:
clearin interfaceCollection<E>- Overrides:
clearin classAbstractCollectionDecorator<E>- Throws:
UnsupportedOperationException- Always thrown.
-
entrySet
-
iterator
-
remove
Always throwsUnsupportedOperationException.- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceMultiSet<E>- Overrides:
removein classAbstractCollectionDecorator<E>- Parameters:
object- Ignored.- Returns:
trueif this call changed the collection.- Throws:
UnsupportedOperationException- Always thrown.
-
remove
Always throwsUnsupportedOperationException.- Specified by:
removein interfaceMultiSet<E>- Overrides:
removein classAbstractMultiSetDecorator<E>- Parameters:
object- Ignored.count- Ignored.- Returns:
- The number of occurrences of the object in the multiset before the operation; possibly zero.
- Throws:
UnsupportedOperationException- Always thrown.
-
removeAll
Always throwsUnsupportedOperationException.- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceMultiSet<E>- Overrides:
removeAllin classAbstractCollectionDecorator<E>- Parameters:
coll- Ignored.- Returns:
trueif this call changed the multiset.- Throws:
UnsupportedOperationException- Always thrown.
-
removeIf
Always throwsUnsupportedOperationException.- Specified by:
removeIfin interfaceCollection<E>- Overrides:
removeIfin classAbstractCollectionDecorator<E>- Parameters:
filter- Ignored.- Throws:
UnsupportedOperationException- Always thrown.- Since:
- 4.4
-
retainAll
Always throwsUnsupportedOperationException.- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceMultiSet<E>- Overrides:
retainAllin classAbstractCollectionDecorator<E>- Parameters:
coll- Ignored.- Returns:
trueif this call changed the multiset.- Throws:
UnsupportedOperationException- Always thrown.
-
setCount
Always throwsUnsupportedOperationException.- Specified by:
setCountin interfaceMultiSet<E>- Overrides:
setCountin classAbstractMultiSetDecorator<E>- Parameters:
object- Ignored.count- Ignored.- Returns:
- The number of occurrences of the object before this operation, zero if the object was not contained in the multiset.
- Throws:
UnsupportedOperationException- Always thrown.
-
uniqueSet
Description copied from interface:MultiSetReturns aSetof unique elements in the MultiSet.Uniqueness constraints are the same as those in
Set.The returned set is backed by this multiset, so any change to either is immediately reflected in the other. Only removal operations are supported, in which case all occurrences of the element are removed from the backing multiset.
-