jconch.pipeline.builder
Class PipelineBuilder<CURRENT_T>

java.lang.Object
  extended by jconch.pipeline.builder.PipelineBuilder<CURRENT_T>

public class PipelineBuilder<CURRENT_T>
extends Object

Class for programmatically building up a pipeline. It provides convenient access to the ThreadingModel and PipeLink of the elements PipelineStage that makes up the tail of the pipeline, as well as enforcing type safety through generics. In addition, it starts the elements (see PipelineStage.start()) as they are attached to the pipeline.

Author:
Robert Fischer

Constructor Summary
PipelineBuilder(Producer<CURRENT_T> start)
          Constructor.
 
Method Summary
 void attachConsumer(Consumer<CURRENT_T> consumer)
          Attaches a consumer onto the end of the pipeline.
<NEW_T> PipelineBuilder<NEW_T>
attachProcessor(Processor<CURRENT_T,NEW_T> processor)
          Attaches a processor onto the end of the pipeline.
 PipeLink<CURRENT_T> getLink()
          Gets the link of the instance.
 ThreadingModel getThreadingModel()
          Gets the threading model of the element which was last attached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PipelineBuilder

public PipelineBuilder(Producer<CURRENT_T> start)
Constructor. Begins the process of building up the pipeline.

Parameters:
start - The producer which starts the pipeline.
Throws:
org.apache.commons.lang.NullArgumentException - If the argument is null.
Method Detail

attachProcessor

public <NEW_T> PipelineBuilder<NEW_T> attachProcessor(Processor<CURRENT_T,NEW_T> processor)
Attaches a processor onto the end of the pipeline.

Type Parameters:
NEW_T - The new type that is being processed.
Parameters:
processor - The processor which will process elements.
Returns:
The builder for the next stage in the pipeline.
Throws:
org.apache.commons.lang.NullArgumentException - If the argument is null.

attachConsumer

public void attachConsumer(Consumer<CURRENT_T> consumer)
Attaches a consumer onto the end of the pipeline.

Parameters:
consumer - The consumer to attach.

getLink

public PipeLink<CURRENT_T> getLink()
Gets the link of the instance.

Returns:
the link.

getThreadingModel

public ThreadingModel getThreadingModel()
Gets the threading model of the element which was last attached.

Returns:
the threading model.