public class ConsumerIterator<T> extends Object implements Iterator<T>, Closeable, ProvidesTotalHint
Iterator
that takes its elements from a Consumer
. This iterator also implements Closeable
. Closing this iterator will
cause the underlying consumer to be closed. If for any reason the underlying
consumer gets closed (either because this iterator closed it or some other
reason), then this iterator will consider that it has not next items.
#Iterator.remove()
operation is not allowed on this instanceConstructor and Description |
---|
ConsumerIterator(Consumer<T> consumer) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying consumer
|
boolean |
hasNext()
Returns true as long as the underlying consumer is not fully consumed nor
closed
|
T |
next()
Gets an item from the consumer and returns it
|
void |
remove()
Not allowed on this implementations
|
int |
size()
returns the total amount of items available for storage/processing.
|
public void close() throws MuleException
close
in interface Closeable
MuleException
- if an exception occurs closing the resourcepublic boolean hasNext()
public T next()
public void remove()
remove
in interface Iterator<T>
UnsupportedOperationException
public int size()
ProvidesTotalHint
size
in interface ProvidesTotalHint
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.