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 voiddelete(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 CoffeePickInventoryTypeopen(io.reactivex.rxjava3.subjects.Subject<CoffeePickInventoryEventType> events, java.nio.file.Path path)Open an inventory.static CoffeePickInventoryTypeopen(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.Pathunpack(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.CoffeePickVerificationverify(java.lang.String id, CoffeePickIsCancelledType cancelled)Verify the archive of the runtime with the given ID.java.nio.file.Pathwrite(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, waitMethods 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:
searchExactin interfaceCoffeePickInventoryType- Parameters:
id- The ID of the runtime- Returns:
- The runtime with the given ID
-
events
Description copied from interface:CoffeePickInventoryTypeAccess the stream of events published by the inventory when the state of the inventory changes.- Specified by:
eventsin interfaceCoffeePickInventoryType- Returns:
- A stream of events
-
search
Description copied from interface:CoffeePickInventoryTypeSearch for all runtimes matching the given parameters.- Specified by:
searchin 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:CoffeePickInventoryTypeSave a runtime. The method calls the given writer method when it needs to write an archive of the runtime to disk.- Specified by:
writein 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:CoffeePickInventoryTypeReturn the path of the given runtime in the inventory if it exists, or nothing if it does not.- Specified by:
pathOfin 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:CoffeePickInventoryTypeUnpack the runtime with the given ID topath. The method takes a functioncancelledthat will be evaluated repeatedly and, if the function returnstrueat any point, the operation will be cancelled.- Specified by:
unpackin interfaceCoffeePickInventoryType- Parameters:
id- The runtime IDtarget_path- The target pathcancelled- A function that returnstrueif 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:CoffeePickInventoryTypeDelete the runtime with the given identifier. Does nothing if no runtime has the given identifier.- Specified by:
deletein 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:CoffeePickInventoryTypeVerify the archive of the runtime with the given ID. The method takes a functioncancelledthat will be evaluated repeatedly and, if the function returnstrueat any point, the operation will be cancelled.- Specified by:
verifyin interfaceCoffeePickInventoryType- Parameters:
id- The identifiercancelled- A function that returnstrueif the operation should be cancelled- Returns:
- The verification results
- Throws:
java.io.IOException- On I/O errors
-