class RemoteChunkingWorkerBuilder {

	@SuppressWarnings({"unchecked", "rawtypes"})
	public IntegrationFlow build() {
		Assert.notNull(this.itemWriter, "An ItemWriter must be provided");
		Assert.notNull(this.inputChannel, "An InputChannel must be provided");
		Assert.notNull(this.outputChannel, "An OutputChannel must be provided");

		if(this.itemProcessor == null) {
			this.itemProcessor = new PassThroughItemProcessor();
		}
		SimpleChunkProcessor<I, O> chunkProcessor = new SimpleChunkProcessor<>(this.itemProcessor, this.itemWriter);

		ChunkProcessorChunkHandler<I> chunkProcessorChunkHandler = new ChunkProcessorChunkHandler<>();
		chunkProcessorChunkHandler.setChunkProcessor(chunkProcessor);

		return IntegrationFlows
				.from(this.inputChannel)
				.handle(chunkProcessorChunkHandler, SERVICE_ACTIVATOR_METHOD_NAME)
				.channel(this.outputChannel)
				.get();
	}

}