Class Pipeline<T>
- java.lang.Object
-
- com.norconex.commons.lang.pipeline.Pipeline<T>
-
- Type Parameters:
T- pipeline context type
- All Implemented Interfaces:
IPipelineStage<T>
public class Pipeline<T> extends Object implements IPipelineStage<T>
Represent a very simple pipeline container for a list of executable tasks called "pipeline stages" (defined usingIPipelineStage). This pipeline class can also be used a pipeline stage to create pipe hierarchies. For more sophisticated work flow needs, consider using a more advanced framework.- Since:
- 1.5.0
- Author:
- Pascal Essiembre
-
-
Constructor Summary
Constructors Constructor Description Pipeline()Constructor.Pipeline(List<IPipelineStage<T>> stages)Creates a new pipeline with the specified stages.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pipeline<T>addStage(IPipelineStage<T> stage)Adds a stage to the pipeline.Pipeline<T>addStages(List<IPipelineStage<T>> stages)Adds stages to the pipeline.voidclearStages()booleanexecute(T context)Executes this pipeline stage.List<IPipelineStage<T>>getStages()Gets the pipeline stages.
-
-
-
Constructor Detail
-
Pipeline
public Pipeline()
Constructor.
-
Pipeline
public Pipeline(List<IPipelineStage<T>> stages)
Creates a new pipeline with the specified stages.- Parameters:
stages- the stages to execute
-
-
Method Detail
-
getStages
public List<IPipelineStage<T>> getStages()
Gets the pipeline stages.- Returns:
- the pipeline stages
-
addStages
public Pipeline<T> addStages(List<IPipelineStage<T>> stages)
Adds stages to the pipeline.- Parameters:
stages- pipeline stages to add- Returns:
- this instance, for chaining
-
addStage
public Pipeline<T> addStage(IPipelineStage<T> stage)
Adds a stage to the pipeline.- Parameters:
stage- pipeline stage to add- Returns:
- this instance, for chaining
-
clearStages
public void clearStages()
-
execute
public boolean execute(T context)
Description copied from interface:IPipelineStageExecutes this pipeline stage. Implementors are encouraged to throwPipelineExceptionupon errors.- Specified by:
executein interfaceIPipelineStage<T>- Parameters:
context- pipeline context- Returns:
- whether to continue pipeline execution or stop (
trueto continue).
-
-