Package io.microsphere.concurrent
Class DelegatingBlockingQueue<E>
- java.lang.Object
-
- io.microsphere.concurrent.DelegatingBlockingQueue<E>
-
- Type Parameters:
E- The type of elements held in this queue.
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.concurrent.BlockingQueue<E>,java.util.Queue<E>
public class DelegatingBlockingQueue<E> extends java.lang.Object implements java.util.concurrent.BlockingQueue<E>A delegating implementation ofBlockingQueuethat wraps anotherBlockingQueueinstance and forwards all method calls to it.This class can be used as a base class for decorators that add functionality to a
BlockingQueue, such as adding instrumentation, validation, or other cross-cutting concerns.Example Usage
BlockingQueue<String> delegate = new LinkedBlockingQueue<>(); DelegatingBlockingQueue<String> queue = new DelegatingBlockingQueue<>(delegate); queue.put("item"); // Adds an element to the queue String item = queue.take(); // Retrieves and removes an element- Since:
- 1.0.0
- Author:
- Mercy
-
-
Constructor Summary
Constructors Constructor Description DelegatingBlockingQueue(java.util.concurrent.BlockingQueue<E> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E e)booleanaddAll(java.util.Collection<? extends E> c)voidclear()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)intdrainTo(java.util.Collection<? super E> c)intdrainTo(java.util.Collection<? super E> c, int maxElements)Eelement()booleanequals(java.lang.Object o)voidforEach(java.util.function.Consumer<? super E> action)inthashCode()booleanisEmpty()java.util.Iterator<E>iterator()booleanoffer(E e)booleanoffer(E e, long timeout, java.util.concurrent.TimeUnit unit)java.util.stream.Stream<E>parallelStream()Epeek()Epoll()Epoll(long timeout, java.util.concurrent.TimeUnit unit)voidput(E e)intremainingCapacity()Eremove()booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanremoveIf(java.util.function.Predicate<? super E> filter)booleanretainAll(java.util.Collection<?> c)intsize()java.util.Spliterator<E>spliterator()java.util.stream.Stream<E>stream()Etake()java.lang.Object[]toArray()<T> T[]toArray(T[] a)java.lang.StringtoString()
-
-
-
Constructor Detail
-
DelegatingBlockingQueue
public DelegatingBlockingQueue(java.util.concurrent.BlockingQueue<E> delegate)
-
-
Method Detail
-
iterator
public java.util.Iterator<E> iterator()
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArrayin interfacejava.util.Collection<E>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArrayin interfacejava.util.Collection<E>
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
- Specified by:
containsAllin interfacejava.util.Collection<E>
-
addAll
public boolean addAll(java.util.Collection<? extends E> c)
- Specified by:
addAllin interfacejava.util.Collection<E>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
- Specified by:
removeAllin interfacejava.util.Collection<E>
-
removeIf
public boolean removeIf(java.util.function.Predicate<? super E> filter)
- Specified by:
removeIfin interfacejava.util.Collection<E>
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
- Specified by:
retainAllin interfacejava.util.Collection<E>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<E>
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equalsin interfacejava.util.Collection<E>- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection<E>- Overrides:
hashCodein classjava.lang.Object
-
spliterator
public java.util.Spliterator<E> spliterator()
-
stream
public java.util.stream.Stream<E> stream()
- Specified by:
streamin interfacejava.util.Collection<E>
-
parallelStream
public java.util.stream.Stream<E> parallelStream()
- Specified by:
parallelStreamin interfacejava.util.Collection<E>
-
add
public boolean add(E e)
-
offer
public boolean offer(E e)
-
put
public void put(E e) throws java.lang.InterruptedException
- Specified by:
putin interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
offer
public boolean offer(E e, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
offerin interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
take
public E take() throws java.lang.InterruptedException
- Specified by:
takein interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
poll
public E poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
pollin interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacityin interfacejava.util.concurrent.BlockingQueue<E>
-
remove
public boolean remove(java.lang.Object o)
-
contains
public boolean contains(java.lang.Object o)
-
drainTo
public int drainTo(java.util.Collection<? super E> c)
- Specified by:
drainToin interfacejava.util.concurrent.BlockingQueue<E>
-
drainTo
public int drainTo(java.util.Collection<? super E> c, int maxElements)
- Specified by:
drainToin interfacejava.util.concurrent.BlockingQueue<E>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<E>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection<E>
-
forEach
public void forEach(java.util.function.Consumer<? super E> action)
- Specified by:
forEachin interfacejava.lang.Iterable<E>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-