E
- the type of elements held in this queuepublic final class UnmodifiableQueue<E> extends AbstractQueueDecorator<E> implements Unmodifiable
Queue
to ensure it can't be altered.
Attempts to modify it will result in an UnsupportedOperationException.
Modifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID
Serialization version
|
Modifier | Constructor and Description |
---|---|
private |
UnmodifiableQueue(java.util.Queue<? extends E> queue)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(java.lang.Object object) |
boolean |
addAll(java.util.Collection<? extends E> coll) |
void |
clear() |
java.util.Iterator<E> |
iterator() |
boolean |
offer(E obj) |
E |
poll() |
private void |
readObject(java.io.ObjectInputStream in)
Read the collection in using a custom routine.
|
E |
remove() |
boolean |
remove(java.lang.Object object) |
boolean |
removeAll(java.util.Collection<?> coll) |
boolean |
removeIf(java.util.function.Predicate<? super E> filter) |
boolean |
retainAll(java.util.Collection<?> coll) |
static <E> java.util.Queue<E> |
unmodifiableQueue(java.util.Queue<? extends E> queue)
Factory method to create an unmodifiable queue.
|
private void |
writeObject(java.io.ObjectOutputStream out)
Write the collection out using a custom routine.
|
decorated, element, peek
contains, containsAll, isEmpty, setCollection, size, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
private static final long serialVersionUID
private UnmodifiableQueue(java.util.Queue<? extends E> queue)
queue
- the queue to decorate, must not be nulljava.lang.NullPointerException
- if queue is nullpublic static <E> java.util.Queue<E> unmodifiableQueue(java.util.Queue<? extends E> queue)
If the queue passed in is already unmodifiable, it is returned.
E
- the type of the elements in the queuequeue
- the queue to decorate, must not be nulljava.lang.NullPointerException
- if queue is nullprivate void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
out
- the output streamjava.io.IOException
- if an I/O error occurs while writing to the output streamprivate void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- the input streamjava.io.IOException
- if an I/O error occurs while reading from the input streamjava.lang.ClassNotFoundException
- if the class of a serialized object can not be foundpublic java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
iterator
in interface java.util.Collection<E>
iterator
in class AbstractCollectionDecorator<E>
public boolean add(java.lang.Object object)
add
in interface java.util.Collection<E>
add
in interface java.util.Queue<E>
add
in class AbstractCollectionDecorator<E>
public boolean addAll(java.util.Collection<? extends E> coll)
addAll
in interface java.util.Collection<E>
addAll
in class AbstractCollectionDecorator<E>
public void clear()
clear
in interface java.util.Collection<E>
clear
in class AbstractCollectionDecorator<E>
public boolean remove(java.lang.Object object)
remove
in interface java.util.Collection<E>
remove
in class AbstractCollectionDecorator<E>
public boolean removeIf(java.util.function.Predicate<? super E> filter)
removeIf
in interface java.util.Collection<E>
removeIf
in class AbstractCollectionDecorator<E>
public boolean removeAll(java.util.Collection<?> coll)
removeAll
in interface java.util.Collection<E>
removeAll
in class AbstractCollectionDecorator<E>
public boolean retainAll(java.util.Collection<?> coll)
retainAll
in interface java.util.Collection<E>
retainAll
in class AbstractCollectionDecorator<E>
public boolean offer(E obj)
offer
in interface java.util.Queue<E>
offer
in class AbstractQueueDecorator<E>
public E poll()
poll
in interface java.util.Queue<E>
poll
in class AbstractQueueDecorator<E>
public E remove()
remove
in interface java.util.Queue<E>
remove
in class AbstractQueueDecorator<E>