org.mule.streaming
Class ListConsumer<T>
java.lang.Object
org.mule.streaming.AbstractConsumer<T,List<T>>
org.mule.streaming.ListConsumer<T>
- All Implemented Interfaces:
- Closeable, Consumer<T>, ProvidesTotalHint
public class ListConsumer<T>
- extends AbstractConsumer<T,List<T>>
Implementation of Consumer
that obains a List
from a Producer
and returns the elements one by one. This implementation
is not thread-safe.
- Since:
- 3.5.0
Method Summary |
protected boolean |
checkConsumed()
Implement this method to actualy check for the Producer being fully
consumed without worrying about it being closed or throwing any exceptions |
void |
close()
Closes the resource. |
protected T |
doConsume()
Implement this method to actually consume the producer without worrying about
exception types or checking fo this consumer to be closed. |
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 |
ListConsumer
public ListConsumer(Producer<List<T>> producer)
doConsume
protected T doConsume()
throws NoSuchElementException
- Implement this method to actually consume the producer without worrying about
exception types or checking fo this consumer to be closed. If the producer is
consumed then simply return
null
- Specified by:
doConsume
in class AbstractConsumer<T,List<T>>
- Returns:
- a new item or
null
- Throws:
NoSuchElementException
checkConsumed
protected boolean checkConsumed()
- Description copied from class:
AbstractConsumer
- Implement this method to actualy check for the
Producer
being fully
consumed without worrying about it being closed or throwing any exceptions
- Specified by:
checkConsumed
in class AbstractConsumer<T,List<T>>
- Returns:
- whether the
Producer
has been consumed or not
size
public int size()
- 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
- Overrides:
size
in class AbstractConsumer<T,List<T>>
close
public void close()
throws MuleException
- Closes the resource. Calling this method is mandatory for any component using
this instance once it finishes using it. This method should not throw
exception is invoked on an instance that has already been closed
- Specified by:
close
in interface Closeable
- Overrides:
close
in class AbstractConsumer<T,List<T>>
- Throws:
MuleException
- if an exception occurs closing the resource
Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.