|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.github.fge.jsonschema.core.processing.ProcessorChain<IN,OUT>
IN - the input type for that chainOUT - the output type for that chain@Immutable public final class ProcessorChain<IN extends MessageProvider,OUT extends MessageProvider>
A processor chain
This class allows to build a chain out of different Processor
instances. Chaining two processors p1 and p2 only requires
that the output of p1 be compatible with the input of p2.
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(...).getProcessor();
// input is of type X
final Y ret = chain.process(report, X);
Note that all instances are immutable: each alteration of the chain returns a new chain. This, for example, will not work:
final ProcessorChain<X, Y> chain = ProcessorChain.startWith(p1);
chain.failOnError(); // WRONG!
chain.getProcessor(); // Will return p1, not p1 with a stop condition
| Method Summary | ||
|---|---|---|
|
chainWith(Processor<OUT,NEWOUT> p)
Add a processor to the chain |
|
ProcessorChain<IN,OUT> |
failOnError()
Stop the processing chain on failure |
|
ProcessorChain<IN,OUT> |
failOnError(ProcessingMessage message)
Stop the processing chain on failure |
|
Processor<IN,OUT> |
getProcessor()
|
|
static
|
startWith(Processor<X,Y> p)
Start a processing chain with a single processor |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <X extends MessageProvider,Y extends MessageProvider> ProcessorChain<X,Y> startWith(Processor<X,Y> p)
X - the input typeY - the output typep - the processor
NullPointerException - processor is nullpublic ProcessorChain<IN,OUT> failOnError()
Inserting this into a chain will stop the processing chain if the
previous processor ended up with an error (ie, ProcessingReport.isSuccess() returns false).
public ProcessorChain<IN,OUT> failOnError(ProcessingMessage message)
Inserting this into a chain will stop the processing chain if the
previous processor ended up with an error (ie, ProcessingReport.isSuccess() returns false).
message - the processing message to use
ProcessingMessage.asException(),
ProcessingMessage.setExceptionProvider(ExceptionProvider)public <NEWOUT extends MessageProvider> ProcessorChain<IN,NEWOUT> chainWith(Processor<OUT,NEWOUT> p)
NEWOUT - the return type for that new processorp - the processor to add
NullPointerException - processor to append is nullpublic Processor<IN,OUT> getProcessor()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||