public class QueueUtils
extends java.lang.Object
Queue
instances.Modifier and Type | Field and Description |
---|---|
static java.util.Queue |
EMPTY_QUEUE
An empty unmodifiable queue.
|
Modifier and Type | Method and Description |
---|---|
static <E> java.util.Queue<E> |
emptyQueue()
Get an empty
Queue . |
static <E> java.util.Queue<E> |
predicatedQueue(java.util.Queue<E> queue,
Predicate<? super E> predicate)
Returns a predicated (validating) queue backed by the given queue.
|
static <E> java.util.Queue<E> |
transformingQueue(java.util.Queue<E> queue,
Transformer<? super E,? extends E> transformer)
Returns a transformed queue backed by the given queue.
|
static <E> java.util.Queue<E> |
unmodifiableQueue(java.util.Queue<? extends E> queue)
Returns an unmodifiable queue backed by the given queue.
|
public static final java.util.Queue EMPTY_QUEUE
public static <E> java.util.Queue<E> unmodifiableQueue(java.util.Queue<? extends E> queue)
E
- the type of the elements in the queuequeue
- the queue to make unmodifiable, must not be nulljava.lang.NullPointerException
- if the queue is nullpublic static <E> java.util.Queue<E> predicatedQueue(java.util.Queue<E> queue, Predicate<? super E> predicate)
Only objects that pass the test in the given predicate can be added to the queue. Trying to add an invalid object results in an IllegalArgumentException. It is important not to use the original queue after invoking this method, as it is a backdoor for adding invalid objects.
E
- the type of the elements in the queuequeue
- the queue to predicate, must not be nullpredicate
- the predicate used to evaluate new elements, must not be nulljava.lang.NullPointerException
- if the queue or predicate is nullpublic static <E> java.util.Queue<E> transformingQueue(java.util.Queue<E> queue, Transformer<? super E,? extends E> transformer)
Each object is passed through the transformer as it is added to the Queue. It is important not to use the original queue after invoking this method, as it is a backdoor for adding untransformed objects.
Existing entries in the specified queue will not be transformed.
If you want that behaviour, see TransformedQueue.transformedQueue(java.util.Queue<E>, org.apache.commons.collections4.Transformer<? super E, ? extends E>)
.
E
- the type of the elements in the queuequeue
- the queue to predicate, must not be nulltransformer
- the transformer for the queue, must not be nulljava.lang.NullPointerException
- if the queue or transformer is nullpublic static <E> java.util.Queue<E> emptyQueue()
Queue
.E
- the type of the elements in the queueQueue
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"