Interface ResourceHandler

All Known Implementing Classes:
CombinedResourceHandler, SingleVariantStorage

public interface ResourceHandler
Something resources can be inserted into or extracted from (ARCHITECTURE.md ยง10.1). Every change happens inside a transaction; nothing is removed before the caller commits.

Implementations must conserve resources: an insert that returns n stores exactly n, an extract that returns n removes exactly n.

  • Method Details

    • insert

      long insert(@NotNull @NotNull ResourceVariant variant, long maxAmount, @NotNull @NotNull TransactionContext transaction)
      Parameters:
      maxAmount - the most to insert; must not be negative
      Returns:
      how much was accepted, between 0 and maxAmount
    • extract

      long extract(@NotNull @NotNull ResourceVariant variant, long maxAmount, @NotNull @NotNull TransactionContext transaction)
      Parameters:
      maxAmount - the most to extract; must not be negative
      Returns:
      how much was removed, between 0 and maxAmount
    • views

      @NotNull @NotNull List<StorageView> views()
      Returns:
      a snapshot of the current contents, one view per slot
    • supportsInsertion

      default boolean supportsInsertion()
    • supportsExtraction

      default boolean supportsExtraction()
    • amountOf

      default long amountOf(@NotNull @NotNull ResourceVariant variant)
      Returns:
      the total amount of exactly variant held