Package org.benf.cfr.reader.api

# Interface OutputSinkFactory

public interface OutputSinkFactory

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static interface`
  `OutputSinkFactory.Sink<T>`
  NB Sink as opposed to a stream, means that implementor has the choice of when to close.
  `static enum`
  `OutputSinkFactory.SinkClass`
  Defines the kind of object that will arrive on your sink.
  All consumers should accept at least STRING.
  Not all classes are appropriate to all sink types.
  `OutputSinkFactory.Sink` instances are constructed, and used in terms of sink classes so as to ensure easy future expansion of capabilities without breaking the ABI, and without being entirely weakly typed.
  `static enum`
  `OutputSinkFactory.SinkType`
  Defines the kind of sink this is.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T> OutputSinkFactory.Sink<T>`
  `getSink(OutputSinkFactory.SinkType sinkType, OutputSinkFactory.SinkClass sinkClass)`
  CFR wishes to sink output - return an implementation of Sink that takes the appropriate input for the SinkClass being sunk, or null.
  `List<OutputSinkFactory.SinkClass>`
  `getSupportedSinks(OutputSinkFactory.SinkType sinkType, Collection<OutputSinkFactory.SinkClass> available)`
  Return the classes of sink that this sink factory can provide for the given sink type.

- ## Method Details

  - ### getSupportedSinks

    List<OutputSinkFactory.SinkClass> getSupportedSinks(OutputSinkFactory.SinkType sinkType, Collection<OutputSinkFactory.SinkClass> available)
    Return the classes of sink that this sink factory can provide for the given sink type. Note. You will always receive SinkClass.STRING, and should always support it. Returning null or an empty list is implicitly equal to returning [SinkClass.STRING].
    Parameters:
      `sinkType` - the kind of sink - see `OutputSinkFactory.SinkType` enum.
      `available` - the classes of data CFR has available for this sink.
    Returns:
      the subset (in preferential order) of available that you are equipped to handle. You will then be receive a call to getSink with one of these (probably the first one!).

  - ### getSink

    <T> OutputSinkFactory.Sink<T> getSink(OutputSinkFactory.SinkType sinkType, OutputSinkFactory.SinkClass sinkClass)
    CFR wishes to sink output - return an implementation of Sink that takes the appropriate input for the SinkClass being sunk, or null. Null will cause a no-op sink to be inferred. Why has sink been done in this weakly typed way? So as to allow easy extension without breaking the ABI of the cfr jar. See `OutputSinkFactory.SinkClass`
    Type Parameters:
      `T` - the type of sinkClass's data. (tut tut!)
    Parameters:
      `sinkType` - the kind of sink - see `OutputSinkFactory.SinkType` enum.
      `sinkClass` - the class of sink. You select this in `getSupportedSinks(SinkType, Collection)`
    Returns:
      a sink capable of accepting sinkClass' data, or null. Null means you don't want the data.