- All Implemented Interfaces:
- Iterator
public class Contractorator
extends Prefetch
A Contractorator is the reverse of an Expanderator. A Contractorator takes a
source Iterator, and consumes elements from it in batches by passing to the
Contractor which returns an object when ready. It is upto the Contractor to
handle termination conditions. For example, it might batch consume the
objects ten at a time with some summary info, but handle that there may be
less than ten elements in the final summary.
A Contractor could also be used to chunk up a number of objects for
serialization, perhaps for network transmission. Such a pattern might be used
with an Expander on the other side to deserialize into an iterator.
- Author:
- Martyn Cutcher