Package com.io7m.coffeepick.runtime.database

# Class RuntimeDescriptionDatabase

java.lang.Object
com.io7m.coffeepick.runtime.database.RuntimeDescriptionDatabase

    @ThreadSafe
    public final class RuntimeDescriptionDatabase
    extends java.lang.Object

A persistent database of runtime descriptions.

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `void` | `add​(RuntimeDescription description)` | Add a runtime to the cache.
  `void` | `delete​(java.lang.String id)` | Delete a runtime from the cache.
  `java.util.Map<java.lang.String,​RuntimeDescription>` | `descriptions()` |
  `static RuntimeDescriptionDatabase` | `open​(java.nio.file.Path path)` | Open an existing, or create a new, on-disk cache.
  `java.util.Optional<java.time.OffsetDateTime>` | `updated()` |

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### open

    public static RuntimeDescriptionDatabase open​(java.nio.file.Path path) throws java.io.IOException
    Open an existing, or create a new, on-disk cache. The cache will be populated from the contents of the given directory if it exists and contains runtime descriptions.
    Parameters:
      `path` - The directory
    Returns:
      A new cache
    Throws:
      `java.io.IOException` - On I/O errors

  - ### updated

    public java.util.Optional<java.time.OffsetDateTime> updated()
    Returns:
      The time of the most recent database update

  - ### add

    public void add​(RuntimeDescription description)
    Add a runtime to the cache. The runtime will be persisted to disk, but no exception will be raised if persisting the file fails.
    Parameters:
      `description` - The runtimes to be added

  - ### delete

    public void delete​(java.lang.String id)
    Delete a runtime from the cache. The runtime will be deleted from disk, but no exception will be raised if deleting the file fails.
    Parameters:
      `id` - The runtimes to be added

  - ### descriptions

    public java.util.Map<java.lang.String,​RuntimeDescription> descriptions()
    Returns:
      A read-only map of the current runtimes