@NoExtend public class ListConsumer<T> extends AbstractConsumer<T,List<T>>
Consumer
that obtains a List
from a Producer
and returns the elements one by one.
This implementation is not thread-safe.producer
Constructor and Description |
---|
ListConsumer(Producer<List<T>> producer) |
Modifier and Type | Method and Description |
---|---|
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() |
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 |
getSize()
Returns
this object's size. |
void |
loadNextPage() |
consume, isConsumed
protected T doConsume() throws NoSuchElementException
null
doConsume
in class AbstractConsumer<T,List<T>>
null
NoSuchElementException
protected boolean checkConsumed()
AbstractConsumer
Producer
being fully consumed without worrying about it being closed
or throwing any exceptionscheckConsumed
in class AbstractConsumer<T,List<T>>
Producer
has been consumed or notpublic int getSize()
this
object's size.
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.
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class AbstractConsumer<T,List<T>>
IOException
public void loadNextPage()
Copyright © 2018. All rights reserved.