Class TrackedStorageImpl
java.lang.Object
com.refinedmods.refinedstorage.api.storage.AbstractProxyStorage
com.refinedmods.refinedstorage.api.storage.tracked.TrackedStorageImpl
- All Implemented Interfaces:
ExtractableStorage,InsertableStorage,Storage,StorageView,TrackedStorage
@API(status=STABLE,
since="2.0.0-milestone.1.4")
public class TrackedStorageImpl
extends AbstractProxyStorage
implements TrackedStorage
-
Field Summary
Fields inherited from class com.refinedmods.refinedstorage.api.storage.AbstractProxyStorage
delegate -
Constructor Summary
ConstructorsConstructorDescriptionTrackedStorageImpl(Storage delegate, TrackedStorageRepository repository, LongSupplier clock) TrackedStorageImpl(Storage delegate, LongSupplier clock) A new tracked storage with an in-memory repository. -
Method Summary
Modifier and TypeMethodDescriptionlongextract(ResourceKey resource, long amount, Action action, Actor actor) Extracts a resource from a storage.findTrackedResourceByActorType(ResourceKey resource, Class<? extends Actor> actorType) Finds the tracked resource by actor type.longinsert(ResourceKey resource, long amount, Action action, Actor actor) Inserts a resource into a storage.Methods inherited from class com.refinedmods.refinedstorage.api.storage.AbstractProxyStorage
getAll, getStoredMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.refinedmods.refinedstorage.api.storage.StorageView
getAll, getStored
-
Constructor Details
-
TrackedStorageImpl
A new tracked storage with an in-memory repository.- Parameters:
delegate- the storage that is being decoratedclock- a supplier for unix timestamps
-
TrackedStorageImpl
public TrackedStorageImpl(Storage delegate, TrackedStorageRepository repository, LongSupplier clock) - Parameters:
delegate- the storage that is being decoratedrepository- a repository for persisting and retrieving tracked resourcesclock- a supplier for unix timestamps
-
-
Method Details
-
insert
Description copied from interface:InsertableStorageInserts a resource into a storage.- Specified by:
insertin interfaceInsertableStorage- Overrides:
insertin classAbstractProxyStorage- Parameters:
resource- the resource, may not be nullamount- the amount, must be larger than 0action- the mode of insertionactor- the source- Returns:
- the amount inserted
-
extract
Description copied from interface:ExtractableStorageExtracts a resource from a storage.- Specified by:
extractin interfaceExtractableStorage- Overrides:
extractin classAbstractProxyStorage- Parameters:
resource- the resource, may not be nullamount- the amount, must be larger than 0action- the mode of extractionactor- the source- Returns:
- the amount extracted
-
findTrackedResourceByActorType
public Optional<TrackedResource> findTrackedResourceByActorType(ResourceKey resource, Class<? extends Actor> actorType) Description copied from interface:TrackedStorageFinds the tracked resource by actor type.- Specified by:
findTrackedResourceByActorTypein interfaceTrackedStorage- Parameters:
resource- the resourceactorType- the actor type- Returns:
- the tracked resource modified by the given actor type, if present
-