Package com.hazelcast.jet.core
Interface Inbox
- All Known Implementing Classes:
TestInbox
public interface Inbox extends Iterable<Object>
A subset of
Queue<Object>
API restricted to the consumer side,
with additional support for bulk draining operations.- Since:
- 3.0
-
Method Summary
Modifier and Type Method Description void
clear()
Removes all items from the inbox.default <E> int
drain(Consumer<E> consumer)
Passes each of this object's items to the supplied consumer until it is empty.default <E> int
drainTo(Collection<E> target)
Drains all elements into the providedCollection
.default <E> int
drainTo(Collection<E> target, int limit)
Drains at mostlimit
elements into the providedCollection
.default <E, M> int
drainTo(Collection<M> target, int limit, Function<E,M> mapper)
Drains and maps at mostlimit
elements into the providedCollection
.boolean
isEmpty()
Returnstrue
if this inbox contains no elements,false
otherwise.Iterator<Object>
iterator()
Returns an iterator over the items in the inbox in the order they would be returned by thepoll()
method.Object
peek()
Retrieves, but does not remove, the head of this inbox, or returnsnull
if it is empty.Object
poll()
Retrieves and removes the head of this inbox, or returnsnull
if it is empty.void
remove()
Removes the head of this inbox.int
size()
Returns the number of objects in the inbox.
-
Method Details
-
isEmpty
boolean isEmpty()Returnstrue
if this inbox contains no elements,false
otherwise. -
peek
Retrieves, but does not remove, the head of this inbox, or returnsnull
if it is empty. -
poll
Retrieves and removes the head of this inbox, or returnsnull
if it is empty. -
remove
void remove()Removes the head of this inbox. This method throws an exception if the inbox is empty.- Throws:
NoSuchElementException
- if this inbox is empty
-
iterator
Returns an iterator over the items in the inbox in the order they would be returned by thepoll()
method.The returned iterator doesn't support the
Iterator.remove()
method. -
clear
void clear()Removes all items from the inbox. -
drainTo
Drains all elements into the providedCollection
.- Parameters:
target
- the collection to drain this object's items into- Returns:
- the number of elements actually drained
-
drainTo
Drains at mostlimit
elements into the providedCollection
.- Parameters:
target
- the collection to drain this object's items intolimit
- the maximum amount of items to drain- Returns:
- the number of elements actually drained
- Since:
- 4.0
-
drainTo
default <E, M> int drainTo(@Nonnull Collection<M> target, int limit, @Nonnull Function<E,M> mapper)Drains and maps at mostlimit
elements into the providedCollection
.- Parameters:
target
- the collection to drain this object's items intolimit
- the maximum amount of items to drainmapper
- mapping function to apply to this object's items- Returns:
- the number of elements actually drained
- Since:
- 4.1
-
drain
Passes each of this object's items to the supplied consumer until it is empty.- Returns:
- the number of elements drained
-
size
int size()Returns the number of objects in the inbox.
-