Class UnmodifiableBag<E>
java.lang.Object
org.apache.commons.collections4.collection.AbstractCollectionDecorator<E>
org.apache.commons.collections4.bag.AbstractBagDecorator<E>
org.apache.commons.collections4.bag.UnmodifiableBag<E>
- Type Parameters:
E- The type of elements in this bag
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Bag<E>,Unmodifiable
@Deprecated
public final class UnmodifiableBag<E>
extends AbstractBagDecorator<E>
implements Unmodifiable
Deprecated.
Decorates another
Bag to ensure it can't be altered.
This class is Serializable from Commons Collections 3.1.
Attempts to modify it will result in an UnsupportedOperationException.
- Since:
- 3.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Always throwsUnsupportedOperationException.booleanDeprecated.Always throwsUnsupportedOperationException.booleanaddAll(Collection<? extends E> coll) Deprecated.Always throwsUnsupportedOperationException.voidclear()Deprecated.Always throwsUnsupportedOperationException.iterator()Deprecated.Returns anIteratorover the entire set of members, including copies due to cardinality.booleanDeprecated.Always throwsUnsupportedOperationException.booleanDeprecated.Always throwsUnsupportedOperationException.booleanremoveAll(Collection<?> coll) Deprecated.Always throwsUnsupportedOperationException.booleanDeprecated.Always throwsUnsupportedOperationException.booleanretainAll(Collection<?> coll) Deprecated.Always throwsUnsupportedOperationException.Deprecated.Returns aSetof unique elements in the Bag.static <E> Bag<E> unmodifiableBag(Bag<? extends E> bag) Deprecated.Factory method to create an unmodifiable bag.Methods inherited from class org.apache.commons.collections4.bag.AbstractBagDecorator
decorated, equals, getCount, hashCodeMethods inherited from class org.apache.commons.collections4.collection.AbstractCollectionDecorator
contains, containsAll, isEmpty, setCollection, size, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.collections4.Bag
containsAll, sizeMethods inherited from interface java.util.Collection
contains, isEmpty, parallelStream, spliterator, stream, toArray, toArray
-
Method Details
-
unmodifiableBag
Deprecated.Factory method to create an unmodifiable bag.If the bag passed in is already unmodifiable, it is returned.
- Type Parameters:
E- The type of the elements in the bag- Parameters:
bag- The bag to decorate, must not be null- Returns:
- An unmodifiable Bag
- Throws:
NullPointerException- if bag is null- Since:
- 4.0
-
add
Deprecated.Always throwsUnsupportedOperationException.- Specified by:
addin interfaceBag<E>- Specified by:
addin interfaceCollection<E>- Overrides:
addin classAbstractCollectionDecorator<E>- Parameters:
object- Ignored.- Returns:
trueif the object was not already in theuniqueSet.- Throws:
UnsupportedOperationException- Always thrown.
-
add
Deprecated.Always throwsUnsupportedOperationException.- Specified by:
addin interfaceBag<E>- Overrides:
addin classAbstractBagDecorator<E>- Parameters:
object- Ignored.count- Ignored.- Returns:
trueif the object was not already in theuniqueSet.- Throws:
UnsupportedOperationException- Always thrown.
-
addAll
Deprecated.Always throwsUnsupportedOperationException.- Specified by:
addAllin interfaceCollection<E>- Overrides:
addAllin classAbstractCollectionDecorator<E>- Parameters:
coll- Ignored.- Throws:
UnsupportedOperationException- Always thrown.
-
clear
Deprecated.Always throwsUnsupportedOperationException.- Specified by:
clearin interfaceCollection<E>- Overrides:
clearin classAbstractCollectionDecorator<E>- Throws:
UnsupportedOperationException- Always thrown.
-
iterator
Deprecated.Description copied from interface:BagReturns anIteratorover the entire set of members, including copies due to cardinality. This iterator is fail-fast and will not tolerate concurrent modifications. -
remove
Deprecated.Always throwsUnsupportedOperationException.- Specified by:
removein interfaceBag<E>- Specified by:
removein interfaceCollection<E>- Overrides:
removein classAbstractCollectionDecorator<E>- Parameters:
object- Ignored.- Returns:
trueif this call changed the collection.- Throws:
UnsupportedOperationException- Always thrown.
-
remove
Deprecated.Always throwsUnsupportedOperationException.- Specified by:
removein interfaceBag<E>- Overrides:
removein classAbstractBagDecorator<E>- Parameters:
object- Ignored.count- Ignored.- Returns:
trueif this call changed the collection.- Throws:
UnsupportedOperationException- Always thrown.
-
removeAll
Deprecated.Always throwsUnsupportedOperationException.- Specified by:
removeAllin interfaceBag<E>- Specified by:
removeAllin interfaceCollection<E>- Overrides:
removeAllin classAbstractCollectionDecorator<E>- Parameters:
coll- Ignored.- Returns:
trueif this call changed the collection.- Throws:
UnsupportedOperationException- Always thrown.
-
removeIf
Deprecated.Always throwsUnsupportedOperationException.- Specified by:
removeIfin interfaceCollection<E>- Overrides:
removeIfin classAbstractCollectionDecorator<E>- Parameters:
filter- Ignored.- Throws:
UnsupportedOperationException- Always thrown.- Since:
- 4.4
-
retainAll
Deprecated.Always throwsUnsupportedOperationException.- Specified by:
retainAllin interfaceBag<E>- Specified by:
retainAllin interfaceCollection<E>- Overrides:
retainAllin classAbstractCollectionDecorator<E>- Parameters:
coll- Ignored.- Returns:
trueif this call changed the collection.- Throws:
UnsupportedOperationException- Always thrown.
-
uniqueSet
Deprecated.Description copied from interface:Bag
-
UnmodifiableMultiSetinstead.