Class GeneratorBridge<S,T>

Object
GeneratorBridge<S,T>
Type Parameters:
S - exposed-type
T - internal-type
All Implemented Interfaces:
Generator<S>, ElementWriter<S>

public class GeneratorBridge<S,T> extends Object implements Generator<S>
Exposes a Generator<T> as if it was an Generator<S>.
Author:
Owen Feehan
  • Method Details

    • createOneToOne

      public static <S, T> GeneratorBridge<S,T> createOneToOne(Generator<T> generator, CheckedFunction<S,T,?> bridge)
      Creates a bridge that maps ONE-TO-ONE from source to destination (i.e. one call to the generator for each source item)
      Type Parameters:
      S - source-type
      T - destination-type
      Parameters:
      generator - the generator that accepts the destination type
      bridge - maps a source-item to one destination-item
      Returns:
      a generator that accepts source-types as iterators, but actually calls a generator that uses destination types
    • createOneToMany

      public static <S, T> GeneratorBridge<S,T> createOneToMany(Generator<T> generator, CheckedFunction<S,Stream<T>,?> bridge)
      Creates a bridge that maps ONE-TO-MANY from source to destination (i.e. one or more calls to the generator for each source item)
      Type Parameters:
      S - source-type
      T - destination-type
      Parameters:
      generator - the generator that accepts the destination type
      bridge - maps a source-item to one or more destination-items
      Returns:
      a generator that accepts source-types as iterators, but actually calls a generator that uses destination types
    • write

      public void write(S element, OutputNameStyle outputNameStyle, ElementOutputter outputter) throws OutputWriteFailedException
      Description copied from interface: ElementWriter
      Writes a non-indexable output (an output that isn't part of a collection of other similar items).
      Specified by:
      write in interface ElementWriter<S>
      Parameters:
      element - the element to write.
      outputNameStyle - how to write output-names.
      outputter - how the element is outputted.
      Throws:
      OutputWriteFailedException - if the write operation fails.
    • writeWithIndex

      public void writeWithIndex(S element, String index, IndexableOutputNameStyle outputNameStyle, ElementOutputter outputter) throws OutputWriteFailedException
      Description copied from interface: ElementWriter
      Writes an indexable output (many outputs of the same type, uniquely identified by an index).
      Specified by:
      writeWithIndex in interface ElementWriter<S>
      Parameters:
      element - the element to write.
      index - a string that uniquely identifies this element compared to others in the same write operation.
      outputNameStyle - how to write output-names.
      outputter - how the element is outputted.
      Throws:
      OutputWriteFailedException - if the write operation fails.