org.mule.streaming
Class ConsumerIterator<T>

java.lang.Object
  extended by org.mule.streaming.ConsumerIterator<T>
All Implemented Interfaces:
Iterator<T>, Closeable, ProvidesTotalHint

public class ConsumerIterator<T>
extends Object
implements Iterator<T>, Closeable, ProvidesTotalHint

Implementation of 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 instance

Since:
3.5.0

Constructor Summary
ConsumerIterator(Consumer<T> consumer)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsumerIterator

public ConsumerIterator(Consumer<T> consumer)
Method Detail

close

public void close()
           throws MuleException
Closes the underlying consumer

Specified by:
close in interface Closeable
Throws:
MuleException - if an exception occurs closing the resource

hasNext

public boolean hasNext()
Returns true as long as the underlying consumer is not fully consumed nor closed

Specified by:
hasNext in interface Iterator<T>

next

public T next()
Gets an item from the consumer and returns it

Specified by:
next in interface Iterator<T>

remove

public void remove()
Not allowed on this implementations

Specified by:
remove in interface Iterator<T>
Throws:
UnsupportedOperationException

size

public int size()
Description copied from interface: ProvidesTotalHint
returns the total amount of items available for storage/processing. In some scenarios, it might not be possible/convenient to actually retrieve this value or it might not be available at this point. -1 is returned in such a case.

Specified by:
size in interface ProvidesTotalHint


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.