T - a type of items produced by Valve APIPausable, Valve<T>, AutoCloseable, Iterable<T>, Collection<T>, BlockingQueue<T>, Queue<T>public class Tank<T> extends Object implements Valve<T>, BlockingQueue<T>, AutoCloseable
Valve reactive API.| Constructor | Description |
|---|---|
Tank(int capacity) |
Creates new instance.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
add(T t) |
|
boolean |
addAll(Collection<? extends T> c) |
|
void |
clear() |
|
void |
close() |
|
boolean |
contains(Object o) |
|
boolean |
containsAll(Collection<?> c) |
|
int |
drainTo(Collection<? super T> c) |
|
int |
drainTo(Collection<? super T> c,
int maxElements) |
|
T |
element() |
|
void |
forEach(Consumer<? super T> action) |
|
void |
handle(BiConsumer<T,Pausable> onData,
Consumer<Throwable> onError,
Runnable onComplete) |
Register data handlers (callbacks).
|
boolean |
isEmpty() |
|
Iterator<T> |
iterator() |
|
boolean |
offer(T t) |
|
boolean |
offer(T t,
long timeout,
TimeUnit unit) |
|
void |
pause() |
Pause data chunks flow until
Pausable.resume(). |
T |
peek() |
|
T |
poll() |
|
T |
poll(long timeout,
TimeUnit unit) |
|
void |
put(T t) |
Inserts the specified element at the tail of this queue, waiting
for space to become available if the queue is full.
|
int |
remainingCapacity() |
|
T |
remove() |
|
boolean |
remove(Object o) |
|
boolean |
removeAll(Collection<?> c) |
|
boolean |
removeIf(Predicate<? super T> filter) |
|
void |
resume() |
Resume data chunks flow after
Pausable.pause(). |
boolean |
retainAll(Collection<?> c) |
|
int |
size() |
|
Spliterator<T> |
spliterator() |
|
T |
take() |
|
Object[] |
toArray() |
|
<T1> T1[] |
toArray(T1[] a) |
|
void |
whenDrain(Runnable drainHandler) |
Provided handler is called a single time when internal capacity is maximally half full and instance is not closed.
|
equals, hashCode, parallelStream, streampublic Tank(int capacity)
capacity - the capacity of this queuepublic void whenDrain(Runnable drainHandler)
drainHandler - an handler of drain eventNullPointerException - if drainHandler is nullpublic void pause()
PausablePausable.resume().public void resume()
PausablePausable.pause().public void handle(BiConsumer<T,Pausable> onData, Consumer<Throwable> onError, Runnable onComplete)
Valvepublic void close()
close in interface AutoCloseablepublic boolean add(T t)
add in interface BlockingQueue<T>add in interface Collection<T>add in interface Queue<T>public boolean addAll(Collection<? extends T> c)
addAll in interface Collection<T>public boolean offer(T t)
public void put(T t) throws InterruptedException
put in interface BlockingQueue<T>InterruptedExceptionNullPointerExceptionIllegalArgumentException - if Tank is closedpublic boolean offer(T t, long timeout, TimeUnit unit) throws InterruptedException
offer in interface BlockingQueue<T>InterruptedExceptionpublic void clear()
clear in interface Collection<T>public T take() throws InterruptedException
take in interface BlockingQueue<T>InterruptedExceptionpublic T poll(long timeout, TimeUnit unit) throws InterruptedException
poll in interface BlockingQueue<T>InterruptedExceptionpublic boolean remove(Object o)
remove in interface BlockingQueue<T>remove in interface Collection<T>public int drainTo(Collection<? super T> c)
drainTo in interface BlockingQueue<T>public int drainTo(Collection<? super T> c, int maxElements)
drainTo in interface BlockingQueue<T>public boolean removeIf(Predicate<? super T> filter)
removeIf in interface Collection<T>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<T>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<T>public int size()
size in interface Collection<T>public boolean isEmpty()
isEmpty in interface Collection<T>public int remainingCapacity()
remainingCapacity in interface BlockingQueue<T>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<T>public boolean contains(Object o)
contains in interface BlockingQueue<T>contains in interface Collection<T>public Object[] toArray()
toArray in interface Collection<T>public <T1> T1[] toArray(T1[] a)
toArray in interface Collection<T>public Spliterator<T> spliterator()
spliterator in interface Collection<T>spliterator in interface Iterable<T>Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.