/** * Start a processing chain with a single processor * * @param p the processor * @param <X> the input type * @param <Y> the output type * @return a single element processing chain * @throws NullPointerException processor is null */ public static <X extends MessageProvider, Y extends MessageProvider> ProcessorChain<X, Y> startWith(final Processor<X, Y> p) { BUNDLE.checkNotNull(p, "processing.nullProcessor"); return new ProcessorChain<X, Y>(p); }
/** * Start a processing chain with a single processor * * @param p the processor * @param <X> the input type * @param <Y> the output type * @return a single element processing chain * @throws NullPointerException processor is null */ public static <X extends MessageProvider, Y extends MessageProvider> ProcessorChain<X, Y> startWith(final Processor<X, Y> p) { BUNDLE.checkNotNull(p, "processing.nullProcessor"); return new ProcessorChain<X, Y>(p); }
/** * Start a processing chain with a single processor * * @param p the processor * @param <X> the input type * @param <Y> the output type * @return a single element processing chain * @throws NullPointerException processor is null */ public static <X extends MessageProvider, Y extends MessageProvider> ProcessorChain<X, Y> startWith(final Processor<X, Y> p) { BUNDLE.checkNotNull(p, "processing.nullProcessor"); return new ProcessorChain<X, Y>(p); }
/** * Stop the processing chain on failure * * <p>Inserting this into a chain will stop the processing chain if the * previous processor ended up with an error (ie, {@link * ProcessingReport#isSuccess()} returns {@code false}).</p> * * @param message the processing message to use * @return a new chain * @see ProcessingMessage#asException() * @see ProcessingMessage#setExceptionProvider(ExceptionProvider) */ public ProcessorChain<IN, OUT> failOnError(final ProcessingMessage message) { final Processor<OUT, OUT> fail = new Processor<OUT, OUT>() { @Override public OUT process(final ProcessingReport report, final OUT input) throws ProcessingException { if (!report.isSuccess()) throw message.asException(); return input; } }; final ProcessorMerger<IN, OUT, OUT> merger = new ProcessorMerger<IN, OUT, OUT>(processor, fail); return new ProcessorChain<IN, OUT>(merger); }
/** * Stop the processing chain on failure * * <p>Inserting this into a chain will stop the processing chain if the * previous processor ended up with an error (ie, {@link * ProcessingReport#isSuccess()} returns {@code false}).</p> * * @param message the processing message to use * @return a new chain * @see ProcessingMessage#asException() * @see ProcessingMessage#setExceptionProvider(ExceptionProvider) */ public ProcessorChain<IN, OUT> failOnError(final ProcessingMessage message) { final Processor<OUT, OUT> fail = new Processor<OUT, OUT>() { @Override public OUT process(final ProcessingReport report, final OUT input) throws ProcessingException { if (!report.isSuccess()) throw message.asException(); return input; } }; final ProcessorMerger<IN, OUT, OUT> merger = new ProcessorMerger<IN, OUT, OUT>(processor, fail); return new ProcessorChain<IN, OUT>(merger); }
/** * Stop the processing chain on failure * * <p>Inserting this into a chain will stop the processing chain if the * previous processor ended up with an error (ie, {@link * ProcessingReport#isSuccess()} returns {@code false}).</p> * * @param message the processing message to use * @return a new chain * @see ProcessingMessage#asException() * @see ProcessingMessage#setExceptionProvider(ExceptionProvider) */ public ProcessorChain<IN, OUT> failOnError(final ProcessingMessage message) { final Processor<OUT, OUT> fail = new Processor<OUT, OUT>() { @Override public OUT process(final ProcessingReport report, final OUT input) throws ProcessingException { if (!report.isSuccess()) throw message.asException(); return input; } }; final ProcessorMerger<IN, OUT, OUT> merger = new ProcessorMerger<IN, OUT, OUT>(processor, fail); return new ProcessorChain<IN, OUT>(merger); }
/** * Add a processor to the chain * * @param p the processor to add * @param <NEWOUT> the return type for that new processor * @return a new chain consisting of the previous chain with the new * processor appended * @throws NullPointerException processor to append is null */ public <NEWOUT extends MessageProvider> ProcessorChain<IN, NEWOUT> chainWith(final Processor<OUT, NEWOUT> p) { BUNDLE.checkNotNull(p, "processing.nullProcessor"); final Processor<IN, NEWOUT> merger = new ProcessorMerger<IN, OUT, NEWOUT>(processor, p); return new ProcessorChain<IN, NEWOUT>(merger); }
/** * Add a processor to the chain * * @param p the processor to add * @param <NEWOUT> the return type for that new processor * @return a new chain consisting of the previous chain with the new * processor appended * @throws NullPointerException processor to append is null */ public <NEWOUT extends MessageProvider> ProcessorChain<IN, NEWOUT> chainWith(final Processor<OUT, NEWOUT> p) { BUNDLE.checkNotNull(p, "processing.nullProcessor"); final Processor<IN, NEWOUT> merger = new ProcessorMerger<IN, OUT, NEWOUT>(processor, p); return new ProcessorChain<IN, NEWOUT>(merger); }
/** * Add a processor to the chain * * @param p the processor to add * @param <NEWOUT> the return type for that new processor * @return a new chain consisting of the previous chain with the new * processor appended * @throws NullPointerException processor to append is null */ public <NEWOUT extends MessageProvider> ProcessorChain<IN, NEWOUT> chainWith(final Processor<OUT, NEWOUT> p) { BUNDLE.checkNotNull(p, "processing.nullProcessor"); final Processor<IN, NEWOUT> merger = new ProcessorMerger<IN, OUT, NEWOUT>(processor, p); return new ProcessorChain<IN, NEWOUT>(merger); }