Class UnmodifiableQueue<E>
java.lang.Object
org.apache.commons.collections4.collection.AbstractCollectionDecorator<E>
org.apache.commons.collections4.queue.AbstractQueueDecorator<E>
org.apache.commons.collections4.queue.UnmodifiableQueue<E>
- Type Parameters:
E- The type of elements held in this queue
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Queue<E>,Unmodifiable
Decorates another
Queue to ensure it can't be altered.
Attempts to modify it will result in an UnsupportedOperationException.
- Since:
- 4.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longSerialization version -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateUnmodifiableQueue(Queue<? extends E> queue) Constructor that wraps (not copies). -
Method Summary
Modifier and TypeMethodDescriptionbooleanAlways throwsUnsupportedOperationException.booleanaddAll(Collection<? extends E> coll) Always throwsUnsupportedOperationException.voidclear()Always throwsUnsupportedOperationException.iterator()booleanAlways throwsUnsupportedOperationException.poll()Always throwsUnsupportedOperationException.private voidDeserializes the collection in using a custom routine.remove()Always throwsUnsupportedOperationException.booleanAlways throwsUnsupportedOperationException.booleanremoveAll(Collection<?> coll) Always throwsUnsupportedOperationException.booleanAlways throwsUnsupportedOperationException.booleanretainAll(Collection<?> coll) Always throwsUnsupportedOperationException.static <E> Queue<E> unmodifiableQueue(Queue<? extends E> queue) Factory method to create an unmodifiable queue.private voidSerializes this object to an ObjectOutputStream.Methods inherited from class org.apache.commons.collections4.queue.AbstractQueueDecorator
decorated, element, peekMethods inherited from class org.apache.commons.collections4.collection.AbstractCollectionDecorator
contains, containsAll, isEmpty, setCollection, size, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, parallelStream, size, spliterator, stream, toArray, toArray
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version- See Also:
-
-
Constructor Details
-
UnmodifiableQueue
Constructor that wraps (not copies).- Parameters:
queue- The queue to decorate, must not be null- Throws:
NullPointerException- if queue is null
-
-
Method Details
-
unmodifiableQueue
Factory method to create an unmodifiable queue.If the queue passed in is already unmodifiable, it is returned.
- Type Parameters:
E- The type of the elements in the queue- Parameters:
queue- The queue to decorate, must not be null- Returns:
- An unmodifiable Queue
- Throws:
NullPointerException- if queue is null
-
add
Always throwsUnsupportedOperationException.- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceQueue<E>- Overrides:
addin classAbstractCollectionDecorator<E>- Parameters:
object- Ignored.- Throws:
UnsupportedOperationException- Always thrown.
-
addAll
Always throwsUnsupportedOperationException.- Specified by:
addAllin interfaceCollection<E>- Overrides:
addAllin classAbstractCollectionDecorator<E>- Parameters:
coll- Ignored.- Throws:
UnsupportedOperationException- Always thrown.
-
clear
public void clear()Always throwsUnsupportedOperationException.- Specified by:
clearin interfaceCollection<E>- Overrides:
clearin classAbstractCollectionDecorator<E>- Throws:
UnsupportedOperationException- Always thrown.
-
iterator
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Overrides:
iteratorin classAbstractCollectionDecorator<E>
-
offer
Always throwsUnsupportedOperationException.- Specified by:
offerin interfaceQueue<E>- Overrides:
offerin classAbstractQueueDecorator<E>- Parameters:
obj- Ignored.- Throws:
UnsupportedOperationException- Always thrown.
-
poll
Always throwsUnsupportedOperationException.- Specified by:
pollin interfaceQueue<E>- Overrides:
pollin classAbstractQueueDecorator<E>- Throws:
UnsupportedOperationException- Always thrown.
-
readObject
Deserializes the collection in using a custom routine.- Parameters:
in- The input stream- Throws:
IOException- Thrown if an I/O error occurs while reading from the input streamClassNotFoundException- if the class of a serialized object cannot be found
-
remove
Always throwsUnsupportedOperationException.- Specified by:
removein interfaceQueue<E>- Overrides:
removein classAbstractQueueDecorator<E>- Throws:
UnsupportedOperationException- Always thrown.
-
remove
Always throwsUnsupportedOperationException.- Specified by:
removein interfaceCollection<E>- Overrides:
removein classAbstractCollectionDecorator<E>- Parameters:
object- Ignored.- Throws:
UnsupportedOperationException- Always thrown.
-
removeAll
Always throwsUnsupportedOperationException.- Specified by:
removeAllin interfaceCollection<E>- Overrides:
removeAllin classAbstractCollectionDecorator<E>- Parameters:
coll- Ignored.- 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>- Overrides:
retainAllin classAbstractCollectionDecorator<E>- Parameters:
coll- Ignored.- Throws:
UnsupportedOperationException- Always thrown.
-
writeObject
Serializes this object to an ObjectOutputStream.- Parameters:
out- The target ObjectOutputStream.- Throws:
IOException- thrown when an I/O errors occur writing to the target stream.
-