Package org.anchoranalysis.io.generator
Class GeneratorBridge<S,T>
Object
GeneratorBridge<S,T>
- Type Parameters:
S
- exposed-typeT
- internal-type
- All Implemented Interfaces:
Generator<S>
,ElementWriter<S>
Exposes a
Generator<T>
as if it was an Generator<S>
.- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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)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)void
write
(S element, OutputNameStyle outputNameStyle, ElementOutputter outputter) Writes a non-indexable output (an output that isn't part of a collection of other similar items).void
writeWithIndex
(S element, String index, IndexableOutputNameStyle outputNameStyle, ElementOutputter outputter) Writes an indexable output (many outputs of the same type, uniquely identified by an index).
-
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-typeT
- destination-type- Parameters:
generator
- the generator that accepts the destination typebridge
- 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-typeT
- destination-type- Parameters:
generator
- the generator that accepts the destination typebridge
- 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 interfaceElementWriter<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 interfaceElementWriter<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.
-