Interface OutputCollector<T,R>

All Known Implementing Classes:
BlobCollector, BlobListCollector, DocumentModelCollector, DocumentModelListCollector, DocumentRefCollector

public interface OutputCollector<T,R>
This interface is used to implement result collectors when an operation method is invoked over an iterable input.

The operation method usually declare a scalar type (e.g. data object) as argument. When the operation method is invoked on an iterator over elements of that type the execution of the chain may help you deal with this by automatically invoking your method over every element in the input iterator. For this to work you should set the collector that should be used by the automatic iteration OperationMethod.collector() in order to construct the method output.

So a collector is in fact collecting the result of each individual invocation over a collections of inputs. The collector will be asked by the chain execution to add an individual result by calling collect(OperationContext, Object). This method is taking as argument the return value of the invocation - so it must accept the same type of object - see T generic type. When all partial results are collected the collector will be asked to return the operation result through the getOutput() method.

So when writing a collector you must ensure that the collected type is compatible with the one returned by the operation method where the collector is used.

IMPORTANT An implementation of this class must explicitly implements this interface (and not through its super classes). This is to ease generic type detections. If not doing so your collector class will be rejected and the operation using it invalid.

Author:
Bogdan Stefanescu
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Collects a new partial result (the result of the last iteration step).
    Gets the final output.
  • Method Details

    • collect

      void collect(OperationContext ctx, T obj) throws OperationException
      Collects a new partial result (the result of the last iteration step).
      Throws:
      OperationException
    • getOutput

      R getOutput()
      Gets the final output. This is usually a list or set of collected objects.