IN
- the input type for that chainOUT
- the output type for that chainpublic final class ProcessorChain<IN extends MessageProvider,OUT extends MessageProvider> extends Object implements Processor<IN,OUT>
This class allows to build a chain out of different Processor
instances. The result behaves like a processor itself, so it can be used in
other chains as well.
Sample usage:
final Processor<X, Y> chain = ProcessorChain.startWith(p1) .chainWith(p2).chainWith(...); // input is of type X final Y ret = chain.process(report, X);
Modifier and Type | Method and Description |
---|---|
<NEWOUT extends MessageProvider> |
chainWith(Processor<OUT,NEWOUT> p2)
Add an existing processor to that chain
|
Processor<IN,OUT> |
end() |
ProcessorChain<IN,OUT> |
failOnError() |
OUT |
process(ProcessingReport report,
IN input)
Process the input
|
static <X extends MessageProvider> |
start() |
static <X extends MessageProvider,Y extends MessageProvider> |
startWith(Processor<X,Y> p)
Start a processing chain with a single processor
|
public static <X extends MessageProvider,Y extends MessageProvider> ProcessorChain<X,Y> startWith(Processor<X,Y> p)
X
- the input typeY
- the output typep
- the processorpublic static <X extends MessageProvider> ProcessorChain<X,X> start()
public ProcessorChain<IN,OUT> failOnError()
public <NEWOUT extends MessageProvider> ProcessorChain<IN,NEWOUT> chainWith(Processor<OUT,NEWOUT> p2)
Note that this returns a new chain.
NEWOUT
- the return type for that new processorp2
- the processor to addpublic OUT process(ProcessingReport report, IN input) throws ProcessingException
Processor
process
in interface Processor<IN extends MessageProvider,OUT extends MessageProvider>
report
- the report to use while processinginput
- the input for this processorProcessingException
- processing failedCopyright © 2013. All Rights Reserved.