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 Summary
Modifier and TypeMethodDescriptiondefault longamountOf(@NotNull ResourceVariant variant) longextract(@NotNull ResourceVariant variant, long maxAmount, @NotNull TransactionContext transaction) longinsert(@NotNull ResourceVariant variant, long maxAmount, @NotNull TransactionContext transaction) default booleandefault boolean@NotNull List<StorageView> views()
-
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
- Returns:
- a snapshot of the current contents, one view per slot
-
supportsInsertion
default boolean supportsInsertion() -
supportsExtraction
default boolean supportsExtraction() -
amountOf
- Returns:
- the total amount of exactly
variantheld
-