Class CheckIfAllowed
Object
CheckIfAllowed
- All Implemented Interfaces:
Writer
Only allows outputs, if the output-name is allowed in the
OutputterChecked
.- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionCheckIfAllowed
(SingleLevelOutputEnabled outputEnabled, Optional<WriterExecuteBeforeEveryOperation> preop, Writer writer) Creates a newCheckIfAllowed
instance. -
Method Summary
Modifier and TypeMethodDescriptioncreateFilenameForWriting
(String outputName, String extension) The path to write a particular output to.createSubdirectory
(String outputName, boolean inheritOutputRulesAndRecording) Maybe creates a subdirectory for writing to.<T> boolean
write
(String outputName, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element) Writes an element using anElementWriter
to the current directory.<T> boolean
writeWithIndex
(IndexableOutputNameStyle outputNameStyle, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element, String index) Writes an indexed-element using anElementWriter
in the current directory.<T> boolean
writeWithoutName
(String outputName, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element) Writes an element using anElementWriter
to the current directory, without including an output name in the path.
-
Constructor Details
-
CheckIfAllowed
public CheckIfAllowed(SingleLevelOutputEnabled outputEnabled, Optional<WriterExecuteBeforeEveryOperation> preop, Writer writer) Creates a newCheckIfAllowed
instance.- Parameters:
outputEnabled
- Whether a particular output is enabled or not?preop
- If defined, execute before every operationwriter
- The writer.
-
-
Method Details
-
createSubdirectory
public Optional<OutputterChecked> createSubdirectory(String outputName, boolean inheritOutputRulesAndRecording) throws OutputWriteFailedException Description copied from interface:Writer
Maybe creates a subdirectory for writing to.- Specified by:
createSubdirectory
in interfaceWriter
- Parameters:
outputName
- the name of the subdirectory. This may determine if an output is allowed or not.inheritOutputRulesAndRecording
- if true, the output rules and recording are inherited from the parent directory. if false, they are not, and all outputs are allowed and are unrecorded.- Returns:
- an output-manager for the directory if it is allowed, otherwise
Optional.empty()
. - Throws:
OutputWriteFailedException
- if the directory creation fails.
-
write
public <T> boolean write(String outputName, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element) throws OutputWriteFailedException Description copied from interface:Writer
Writes an element using anElementWriter
to the current directory.- Specified by:
write
in interfaceWriter
- Parameters:
outputName
- the name of the subdirectory. This may determine if an output is allowed or not.elementWriter
- writes the element to the filesystem.element
- the element to write.- Returns:
- true if the output was allowed, false otherwise.
- Throws:
OutputWriteFailedException
- if the write operation fails.
-
writeWithIndex
public <T> boolean writeWithIndex(IndexableOutputNameStyle outputNameStyle, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element, String index) throws OutputWriteFailedException Description copied from interface:Writer
Writes an indexed-element using anElementWriter
in the current directory.- Specified by:
writeWithIndex
in interfaceWriter
- Parameters:
outputNameStyle
- how to combine a particular output-name with an index.elementWriter
- writes the element to the filesystem.element
- the element to write.index
- the index.- Returns:
- true if the output was allowed, false otherwise.
- Throws:
OutputWriteFailedException
- if the write operation fails.
-
writeWithoutName
public <T> boolean writeWithoutName(String outputName, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element) throws OutputWriteFailedException Description copied from interface:Writer
Writes an element using anElementWriter
to the current directory, without including an output name in the path.- Specified by:
writeWithoutName
in interfaceWriter
- Parameters:
outputName
- the name of the subdirectory. This may determine if an output is allowed or not, but will not be included in the outputted filename.elementWriter
- writes the element to the filesystem.element
- the element to write.- Returns:
- true if the output was allowed, false otherwise.
- Throws:
OutputWriteFailedException
- if the write operation fails.
-
createFilenameForWriting
Description copied from interface:Writer
The path to write a particular output to.This is an alternative method to write to the file system rather than using an
ElementWriter
andWriter.write(String, ElementWriterSupplier, ElementSupplier)
andWriter.writeWithIndex(IndexableOutputNameStyle, ElementWriterSupplier, ElementSupplier, String)
.- Specified by:
createFilenameForWriting
in interfaceWriter
- Parameters:
outputName
- the output-name. This is the filename without an extension, and may determine if an output is allowed or not.extension
- the extension- Returns:
- the path to write to, if it is allowed, otherwise
Optional.empty()
.
-