Class LabelledResultsCSVWriter
Object
LabelledResultsCSVWriter
Allows results to be written to a
FeatureCSVWriter, possibly adding further processing.- Author:
- Owen Feehan
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FeatureCSVMetadataForOutputMetadata defining which CSV file to write to, and which headers. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLabelledResultsCSVWriter(FeatureCSVMetadataForOutput outputMetadata, FeatureCSVWriterFactory writerCreator, Optional<Consumer<LabelledResultsVector>> consumeAfterAdding) Creates a newLabelledResultsCSVWriterinstance. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidadd(LabelledResultsVector results) Adds a results-element to be written.protected Optional<FeatureCSVWriter> createWriter(FeatureCSVMetadata csvMetadata) Creates aCSVWriter.abstract voidend()Stops writing the CSV file.protected voidmaybeConsumeResults(LabelledResultsVector results) Consumes theLabelledResultsVectorifconsumeAfterAddingis present.abstract voidstart()Starts writing the CSV file.
-
Field Details
-
outputMetadata
Metadata defining which CSV file to write to, and which headers.
-
-
Constructor Details
-
LabelledResultsCSVWriter
protected LabelledResultsCSVWriter(FeatureCSVMetadataForOutput outputMetadata, FeatureCSVWriterFactory writerCreator, Optional<Consumer<LabelledResultsVector>> consumeAfterAdding) Creates a newLabelledResultsCSVWriterinstance.- Parameters:
outputMetadata- Metadata defining which CSV file to write to, and which headers.writerCreator- Creates aFeatureCSVWriterfor writing the non-aggregated feature results.consumeAfterAdding- After adding aLabelledResultsVector, this function is also called, if it is defined.
-
-
Method Details
-
start
Starts writing the CSV file.This should be called once, before any calls to
add(LabelledResultsVector).- Throws:
OutputWriteFailedException- if the output file cannot be created.
-
add
Adds a results-element to be written.This should be called once for each set of results to be written.
- Parameters:
results- the results.
-
end
Stops writing the CSV file.This should be called once, after all calls to
add(LabelledResultsVector).- Throws:
OutputWriteFailedException- if the output file cannot be created.
-
createWriter
protected Optional<FeatureCSVWriter> createWriter(FeatureCSVMetadata csvMetadata) throws OutputWriteFailedException Creates aCSVWriter.- Parameters:
csvMetadata- the metadata for the writer.- Returns:
- the newly-created writer, if possible.
- Throws:
OutputWriteFailedException- if the CSV file cannot be created successfully.
-
maybeConsumeResults
Consumes theLabelledResultsVectorifconsumeAfterAddingis present.- Parameters:
results- the results to maybe consume.
-