public class InMemoryBinaryService extends Object implements BinaryService
BinaryService
that stores its contents in memory, for testing.Constructor and Description |
---|
InMemoryBinaryService() |
Modifier and Type | Method and Description |
---|---|
String |
generateIdentifier()
Get a new identifier.
|
CompletionStage<? extends Binary> |
get(IRI identifier)
Get a resource by the given identifier.
|
CompletionStage<Void> |
purgeContent(IRI identifier)
Purge the content from its corresponding datastore.
|
CompletionStage<Void> |
setContent(BinaryMetadata meta,
InputStream bytes)
Set the content for a binary object.
|
public CompletionStage<? extends Binary> get(IRI identifier)
RetrievalService
get
in interface RetrievalService<Binary>
identifier
- the resource identifierpublic CompletionStage<Void> setContent(BinaryMetadata meta, InputStream bytes)
BinaryService
setContent
in interface BinaryService
meta
- the binary metadatabytes
- the contentpublic CompletionStage<Void> purgeContent(IRI identifier)
BinaryService
purgeContent
in interface BinaryService
identifier
- the binary object identifierCompletionStage
will complete exceptionally and can be handled with
CompletionStage.handle(java.util.function.BiFunction<? super T, java.lang.Throwable, ? extends U>)
, CompletionStage.exceptionally(java.util.function.Function<java.lang.Throwable, ? extends T>)
or similar methods.public String generateIdentifier()
BinaryService
generateIdentifier
in interface BinaryService