FileStorage


public final class FileStorage<T extends Object> implements Storage


The Java IO File version of the Storage interface. Is able to read and write T to a given file location.

Summary

Public constructors

<T extends Object> FileStorage(
    @NonNull Serializer<@NonNull T> serializer,
    @NonNull Function1<@NonNull File, @NonNull InterProcessCoordinator> coordinatorProducer,
    @NonNull Function0<@NonNull File> produceFile
)

Public methods

@NonNull StorageConnection<@NonNull T>

Creates a storage connection which allows reading and writing to the underlying storage.

Public constructors

FileStorage

public <T extends Object> FileStorage(
    @NonNull Serializer<@NonNull T> serializer,
    @NonNull Function1<@NonNull File, @NonNull InterProcessCoordinator> coordinatorProducer,
    @NonNull Function0<@NonNull File> produceFile
)
Parameters
@NonNull Serializer<@NonNull T> serializer

The serializer that can write T to and from a byte array.

@NonNull Function1<@NonNull File, @NonNull InterProcessCoordinator> coordinatorProducer

The producer to provide InterProcessCoordinator that coordinates IO operations across processes if needed. By default it provides single process coordinator, which doesn't support cross process use cases.

@NonNull Function0<@NonNull File> produceFile

The file producer that returns the file that will be read and written.

Public methods

createConnection

Added in 1.1.1
public @NonNull StorageConnection<@NonNull T> createConnection()

Creates a storage connection which allows reading and writing to the underlying storage.

Should be closed after usage.

Throws
java.io.IOException

Unrecoverable IO exception when trying to access the underlying storage.