class AggregateItemReader<T> implements ItemReader<List<T>> {

	private static final Log LOG = LogFactory.getLog(AggregateItemReader.class);

	private ItemReader<AggregateItem<T>> itemReader;

	/**
	 * Get the next list of records.
	 *
	 * @see org.springframework.batch.item.ItemReader#read()
	 */
	@Nullable
	@Override
	public List<T> read() throws Exception {
		ResultHolder holder = new ResultHolder();

		while (process(itemReader.read(), holder)) {
			continue;
		}

		if (!holder.isExhausted()) {
			return holder.getRecords();
		}
		else {
			return null;
		}
	}

	private boolean process(AggregateItem<T> value, ResultHolder holder) {<FILL_FUNCTION_BODY>}

	public void setItemReader(ItemReader<AggregateItem<T>> itemReader) {
		this.itemReader = itemReader;
	}

	/**
	 * Private class for temporary state management while item is being collected.
	 *
	 * @author Dave Syer
	 *
	 */
	private class ResultHolder {

		private final List<T> records = new ArrayList<>();

		private boolean exhausted = false;

		public List<T> getRecords() {
			return records;
		}

		public boolean isExhausted() {
			return exhausted;
		}

		public void addRecord(T record) {
			records.add(record);
		}

		public void setExhausted(boolean exhausted) {
			this.exhausted = exhausted;
		}

	}

}

		// finish processing if we hit the end of file
		if (value == null) {
			LOG.debug("Exhausted ItemReader");
			holder.setExhausted(true);
			return false;
		}

		// start a new collection
		if (value.isHeader()) {
			LOG.debug("Start of new record detected");
			return true;
		}

		// mark we are finished with current collection
		if (value.isFooter()) {
			LOG.debug("End of record detected");
			return false;
		}

		// add a simple record to the current collection
		if (LOG.isDebugEnabled()) {
			LOG.debug("Mapping: " + value);
		}
		holder.addRecord(value.getItem());
		return true;
	
<no_super_class>