Class CoffeePickInventory
java.lang.Object
com.io7m.coffeepick.client.vanilla.CoffeePickInventory
- All Implemented Interfaces:
CoffeePickInventoryType
public final class CoffeePickInventory extends java.lang.Object implements CoffeePickInventoryType
An inventory of downloaded runtimes.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.io7m.coffeepick.api.CoffeePickInventoryType
CoffeePickInventoryType.RuntimeCancellableArchiveWriterType, CoffeePickInventoryType.UnpackOption
-
Method Summary
Modifier and Type Method Description void
delete(java.lang.String id)
Delete the runtime with the given identifier.io.reactivex.rxjava3.core.Observable<CoffeePickInventoryEventType>
events()
Access the stream of events published by the inventory when the state of the inventory changes.static CoffeePickInventoryType
open(io.reactivex.rxjava3.subjects.Subject<CoffeePickInventoryEventType> events, java.nio.file.Path path)
Open an inventory.static CoffeePickInventoryType
open(io.reactivex.rxjava3.subjects.Subject<CoffeePickInventoryEventType> events, org.apache.commons.compress.archivers.ArchiveStreamFactory archives, org.apache.commons.compress.compressors.CompressorStreamFactory compressors, java.nio.file.Path path)
Open an inventory.java.util.Optional<java.nio.file.Path>
pathOf(java.lang.String id)
Return the path of the given runtime in the inventory if it exists, or nothing if it does not.java.util.Map<java.lang.String,RuntimeDescription>
search(CoffeePickSearch parameters)
Search for all runtimes matching the given parameters.java.util.Optional<RuntimeDescription>
searchExact(java.lang.String id)
java.nio.file.Path
unpack(java.lang.String id, java.nio.file.Path target_path, CoffeePickIsCancelledType cancelled, java.util.Set<CoffeePickInventoryType.UnpackOption> options)
Unpack the runtime with the given ID topath
.CoffeePickVerification
verify(java.lang.String id, CoffeePickIsCancelledType cancelled)
Verify the archive of the runtime with the given ID.java.nio.file.Path
write(RuntimeDescription description, CoffeePickInventoryType.RuntimeCancellableArchiveWriterType writer)
Save a runtime.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.io7m.coffeepick.api.CoffeePickInventoryType
searchAll, unpack, unpack, verify
-
Method Details
-
open
public static CoffeePickInventoryType open(io.reactivex.rxjava3.subjects.Subject<CoffeePickInventoryEventType> events, java.nio.file.Path path) throws java.io.IOExceptionOpen an inventory.- Parameters:
events
- The receiver of eventspath
- The path of the inventory- Returns:
- An inventory
- Throws:
java.io.IOException
- On I/O errors
-
open
public static CoffeePickInventoryType open(io.reactivex.rxjava3.subjects.Subject<CoffeePickInventoryEventType> events, org.apache.commons.compress.archivers.ArchiveStreamFactory archives, org.apache.commons.compress.compressors.CompressorStreamFactory compressors, java.nio.file.Path path) throws java.io.IOExceptionOpen an inventory.- Parameters:
events
- The receiver of eventsarchives
- A factory for archive streamscompressors
- A factory for compressorspath
- The path of the inventory- Returns:
- An inventory
- Throws:
java.io.IOException
- On I/O errors
-
searchExact
- Specified by:
searchExact
in interfaceCoffeePickInventoryType
- Parameters:
id
- The ID of the runtime- Returns:
- The runtime with the given ID
-
events
Description copied from interface:CoffeePickInventoryType
Access the stream of events published by the inventory when the state of the inventory changes.- Specified by:
events
in interfaceCoffeePickInventoryType
- Returns:
- A stream of events
-
search
Description copied from interface:CoffeePickInventoryType
Search for all runtimes matching the given parameters.- Specified by:
search
in interfaceCoffeePickInventoryType
- Parameters:
parameters
- The parameters- Returns:
- The matching runtimes
-
write
public java.nio.file.Path write(RuntimeDescription description, CoffeePickInventoryType.RuntimeCancellableArchiveWriterType writer) throws java.io.IOExceptionDescription copied from interface:CoffeePickInventoryType
Save a runtime. The method calls the given writer method when it needs to write an archive of the runtime to disk.- Specified by:
write
in interfaceCoffeePickInventoryType
- Parameters:
description
- The runtime runtimeswriter
- A function that will be called to write data- Returns:
- The path of the saved archive
- Throws:
java.io.IOException
- On I/O errors
-
pathOf
public java.util.Optional<java.nio.file.Path> pathOf(java.lang.String id) throws java.io.IOExceptionDescription copied from interface:CoffeePickInventoryType
Return the path of the given runtime in the inventory if it exists, or nothing if it does not.- Specified by:
pathOf
in interfaceCoffeePickInventoryType
- Parameters:
id
- The identifier- Returns:
- The path to the runtime if it is installed
- Throws:
java.io.IOException
- On I/O errors
-
unpack
public java.nio.file.Path unpack(java.lang.String id, java.nio.file.Path target_path, CoffeePickIsCancelledType cancelled, java.util.Set<CoffeePickInventoryType.UnpackOption> options) throws java.io.IOExceptionDescription copied from interface:CoffeePickInventoryType
Unpack the runtime with the given ID topath
. The method takes a functioncancelled
that will be evaluated repeatedly and, if the function returnstrue
at any point, the operation will be cancelled.- Specified by:
unpack
in interfaceCoffeePickInventoryType
- Parameters:
id
- The runtime IDtarget_path
- The target pathcancelled
- A function that returnstrue
if the operation should be cancelledoptions
- The unpacking options- Returns:
- The path of the unpacked archive
- Throws:
java.io.IOException
- On I/O errors
-
delete
public void delete(java.lang.String id) throws java.io.IOExceptionDescription copied from interface:CoffeePickInventoryType
Delete the runtime with the given identifier. Does nothing if no runtime has the given identifier.- Specified by:
delete
in interfaceCoffeePickInventoryType
- Parameters:
id
- The identifier- Throws:
java.io.IOException
- On I/O errors
-
verify
public CoffeePickVerification verify(java.lang.String id, CoffeePickIsCancelledType cancelled) throws java.io.IOExceptionDescription copied from interface:CoffeePickInventoryType
Verify the archive of the runtime with the given ID. The method takes a functioncancelled
that will be evaluated repeatedly and, if the function returnstrue
at any point, the operation will be cancelled.- Specified by:
verify
in interfaceCoffeePickInventoryType
- Parameters:
id
- The identifiercancelled
- A function that returnstrue
if the operation should be cancelled- Returns:
- The verification results
- Throws:
java.io.IOException
- On I/O errors
-