public interface TaskFileStore<T extends util.object.Identifiable>
Identifiable
task
ID's.Modifier and Type | Method and Description |
---|---|
void |
add(T taskId,
util.lambda.ConsumerE<java.io.OutputStream> contentWriter)
Writes a file associated to the specified task.
|
void |
add(T taskId,
java.nio.file.Path contentSource)
Writes a file associated to the specified task by taking the contents
from a source file.
|
default void |
add(T taskId,
java.lang.String content)
Writes a file associated to the specified task.
|
java.util.stream.Stream<T> |
listTaskIds() |
java.nio.file.Path |
pathFor(T taskId)
Builds the path to the file associated to the given task ID.
|
void |
remove(T taskId)
Deletes the file associated to the specified task ID.
|
default void |
replace(T taskId,
util.lambda.FunctionE<java.lang.String,java.lang.String> setter)
Uses a
setter function to replace the content of the file
associated to the specified task. |
void |
replace(T taskId,
StreamFilter filter)
Uses a
filter function to replace the content of the file
associated to the specified task. |
java.nio.file.Path pathFor(T taskId)
taskId
- the task ID.java.lang.NullPointerException
- if the argument is null
.java.util.stream.Stream<T> listTaskIds()
The following checked exceptions are rethrown as unchecked (i.e.
the exception is masked as a runtime exception and thrown as is without
wrapping it in a RuntimeException
):
IOException
if an I/O occurs.
void remove(T taskId)
taskId
- the task ID.java.lang.NullPointerException
- if the argument is null
.
The following checked exceptions are rethrown as unchecked (i.e.
the exception is masked as a runtime exception and thrown as is without
wrapping it in a RuntimeException
):
IOException
if an I/O occurs.
void add(T taskId, util.lambda.ConsumerE<java.io.OutputStream> contentWriter)
taskId
- identifies the task.contentWriter
- writes the file contents into an output stream.java.lang.NullPointerException
- if any argument is null
.
The following checked exceptions are rethrown as unchecked (i.e.
the exception is masked as a runtime exception and thrown as is without
wrapping it in a RuntimeException
):
IOException
if an I/O occurs.
default void add(T taskId, java.lang.String content)
taskId
- identifies the task.content
- the file contents.java.lang.NullPointerException
- if any argument is null
.
The following checked exceptions are rethrown as unchecked (i.e.
the exception is masked as a runtime exception and thrown as is without
wrapping it in a RuntimeException
):
IOException
if an I/O occurs.
void add(T taskId, java.nio.file.Path contentSource)
taskId
- identifies the task.contentSource
- the file contents to use.java.lang.NullPointerException
- if any argument is null
.
The following checked exceptions are rethrown as unchecked (i.e.
the exception is masked as a runtime exception and thrown as is without
wrapping it in a RuntimeException
):
IOException
if an I/O occurs.
void replace(T taskId, StreamFilter filter)
filter
function to replace the content of the file
associated to the specified task.taskId
- identifies the task.filter
- gets passed the current content of the file and produces
the new file content.java.lang.NullPointerException
- if any argument is null
.java.lang.IllegalArgumentException
- if there's no file associated to the
specified task.
The following checked exceptions are rethrown as unchecked (i.e.
the exception is masked as a runtime exception and thrown as is without
wrapping it in a RuntimeException
):
Exception
if any other kind of error occurs.
replace(Identifiable, FunctionE)
default void replace(T taskId, util.lambda.FunctionE<java.lang.String,java.lang.String> setter)
setter
function to replace the content of the file
associated to the specified task.
This method reads the entire file content into memory as a string s
using the default character encoding, calls setter
with s
as an argument, and overrides the old file contents with the returned
string.taskId
- identifies the task.setter
- gets passed the current content of the file and produces
the new file content.java.lang.NullPointerException
- if any argument is null
.java.lang.IllegalArgumentException
- if there's no file associated to the
specified task.
The following checked exceptions are rethrown as unchecked (i.e.
the exception is masked as a runtime exception and thrown as is without
wrapping it in a RuntimeException
):
Exception
if any other kind of error occurs.
replace(Identifiable, StreamFilter)