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
ConstructorDescriptionTrackedStorageImpl
(Storage delegate, TrackedStorageRepository repository, LongSupplier clock) TrackedStorageImpl
(Storage delegate, LongSupplier clock) A new tracked storage with an in-memory repository. -
Method Summary
Modifier and TypeMethodDescriptionlong
extract
(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.long
insert
(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, getStored
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:InsertableStorage
Inserts a resource into a storage.- Specified by:
insert
in interfaceInsertableStorage
- Overrides:
insert
in 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:ExtractableStorage
Extracts a resource from a storage.- Specified by:
extract
in interfaceExtractableStorage
- Overrides:
extract
in 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:TrackedStorage
Finds the tracked resource by actor type.- Specified by:
findTrackedResourceByActorType
in interfaceTrackedStorage
- Parameters:
resource
- the resourceactorType
- the actor type- Returns:
- the tracked resource modified by the given actor type, if present
-