Package com.palantir.common.base
Class AbstractBatchingVisitable<T>
- java.lang.Object
-
- com.palantir.common.base.AbstractBatchingVisitable<T>
-
- All Implemented Interfaces:
BatchingVisitable<T>
- Direct Known Subclasses:
BatchingVisitableFromIterable
public abstract class AbstractBatchingVisitable<T> extends Object implements BatchingVisitable<T>
This abstract class will implement the required methods inBatchingVisitable
and will also implement the requires batchSize guarantee (only the last page is allowed to be smaller than the batch size).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractBatchingVisitable.ConsistentVisitor<T,K extends Exception>
-
Constructor Summary
Constructors Constructor Description AbstractBatchingVisitable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <K extends Exception>
booleanbatchAccept(int batchSize, AbortingVisitor<? super List<T>,K> v)
This method should be used to visit elements in batches until the visitor returns false or there are no batches left to visit.protected abstract <K extends Exception>
voidbatchAcceptSizeHint(int batchSizeHint, AbstractBatchingVisitable.ConsistentVisitor<T,K> v)
The batch size passed to this method is purely a hint.
-
-
-
Method Detail
-
batchAccept
public final <K extends Exception> boolean batchAccept(int batchSize, AbortingVisitor<? super List<T>,K> v) throws K extends Exception
Description copied from interface:BatchingVisitable
This method should be used to visit elements in batches until the visitor returns false or there are no batches left to visit.- Specified by:
batchAccept
in interfaceBatchingVisitable<T>
- Parameters:
batchSize
- Each list passed to the visitor will be of batchSize except for the last one which could be smaller, but will not be empty;- Returns:
- true if the visitor always returned true or was never called. false if the visitor ever returned false.
- Throws:
K extends Exception
-
batchAcceptSizeHint
protected abstract <K extends Exception> void batchAcceptSizeHint(int batchSizeHint, AbstractBatchingVisitable.ConsistentVisitor<T,K> v) throws K extends Exception
The batch size passed to this method is purely a hint. The underlying impl can batch up pages however it wants and pass them to the visitor. Batch size consistency is already taken care of by theAbstractBatchingVisitable.ConsistentVisitor
.- Throws:
K extends Exception
-
-