jconch.pipeline
Class Consumer<T>

java.lang.Object
  extended by jconch.pipeline.PipelineStage
      extended by jconch.pipeline.Consumer<T>
Direct Known Subclasses:
ClosureConsumer, CollectionConsumer

public abstract class Consumer<T>
extends PipelineStage

The base implementation of a pipe that consumes elements without producing anything.

Author:
Robert Fischer

Constructor Summary
protected Consumer(ThreadingModel threading, PipeLink<T> in)
          Creates a new instance of Consumer.
 
Method Summary
abstract  void consumeItem(T item)
          Responsible for consuming items.
 void execute()
          Fetches an object and calls consumeItem(Object) on it.
 PipeLink<T> getLinkIn()
          Provides the pipe link that is being drawn from.
 boolean isFinished()
          In addition to the super implementation, it checks for error conditions.
 
Methods inherited from class jconch.pipeline.PipelineStage
getThreadingModel, isStarted, logMessage, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Consumer

protected Consumer(ThreadingModel threading,
                   PipeLink<T> in)
Creates a new instance of Consumer.

Parameters:
threading - The model for this consumer to use.
in - The link into this stage.
Throws:
org.apache.commons.lang.NullArgumentException - If either argument is null
Method Detail

consumeItem

public abstract void consumeItem(T item)
Responsible for consuming items.

Parameters:
item - The item to consume; never null

execute

public final void execute()
Fetches an object and calls consumeItem(Object) on it.

Specified by:
execute in class PipelineStage

isFinished

public boolean isFinished()
In addition to the super implementation, it checks for error conditions. If the pipeline is not supposed to handle any more elements, either because of an error or because a producer is exhausted.

Specified by:
isFinished in class PipelineStage
Returns:
If the pipeline is done producing/consuming elements.

getLinkIn

public PipeLink<T> getLinkIn()
Provides the pipe link that is being drawn from.

Returns:
The inbound pipe link.