Class CompositeStorageImpl
java.lang.Object
com.refinedmods.refinedstorage.api.storage.composite.CompositeStorageImpl
- All Implemented Interfaces:
CompositeAwareChild,CompositeStorage,ParentComposite,ExtractableStorage,InsertableStorage,Storage,StorageView,TrackedStorage
@API(status=STABLE,
since="2.0.0-milestone.1.0")
public class CompositeStorageImpl
extends Object
implements CompositeStorage, CompositeAwareChild, ParentComposite
An implementation of
CompositeStorage that can be contained into other CompositeStorages.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.refinedmods.refinedstorage.api.storage.composite.CompositeAwareChild
CompositeAwareChild.Amount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a source and resorts them.voidaddToCache(ResourceKey resource, long amount) Adds a resource to the composite storage cache.voidClears all sources.compositeExtract(ResourceKey resource, long amount, Action action, Actor actor) Extracts a resource from a storage.compositeInsert(ResourceKey resource, long amount, Action action, Actor actor) Inserts a resource into a storage.booleanlongextract(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.getAll()longlonginsert(ResourceKey resource, long amount, Action action, Actor actor) Inserts a resource into a storage.voidonAddedIntoComposite(ParentComposite parentComposite) Called by aCompositeStoragewhen thisCompositeAwareChildis added into the composite storage.voidonRemovedFromComposite(ParentComposite parentComposite) Called by aCompositeStoragewhen thisCompositeAwareChildis removed from the composite storage.voidonSourceAddedToChild(Storage source) Called by theCompositeAwareChildto notify to this parent composite storage that a source has been added.voidonSourceRemovedFromChild(Storage source) Called by theCompositeAwareChildto notify to this parent composite storage that a source has been removed.voidremoveFromCache(ResourceKey resource, long amount) Removes a resource from the composite storage cache.voidremoveSource(Storage source) Removes a source and resorts them.voidSorts storages that implementPriorityProvider.
-
Constructor Details
-
CompositeStorageImpl
- Parameters:
list- the backing list of this composite storage, used to retrieve a view of the sources
-
-
Method Details
-
sortSources
public void sortSources()Description copied from interface:CompositeStorageSorts storages that implementPriorityProvider.- Specified by:
sortSourcesin interfaceCompositeStorage
-
addSource
Description copied from interface:CompositeStorageAdds a source and resorts them.- Specified by:
addSourcein interfaceCompositeStorage- Parameters:
source- the source
-
removeSource
Description copied from interface:CompositeStorageRemoves a source and resorts them.- Specified by:
removeSourcein interfaceCompositeStorage- Parameters:
source- the source
-
getSources
- Specified by:
getSourcesin interfaceCompositeStorage- Returns:
- an unmodifiable source list
-
clearSources
public void clearSources()Description copied from interface:CompositeStorageClears all sources.- Specified by:
clearSourcesin interfaceCompositeStorage
-
contains
- Specified by:
containsin interfaceCompositeAwareChild
-
extract
Description copied from interface:ExtractableStorageExtracts a resource from a storage.- Specified by:
extractin interfaceExtractableStorage- 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
-
insert
Description copied from interface:InsertableStorageInserts a resource into a storage.- Specified by:
insertin interfaceInsertableStorage- 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
-
getAll
- Specified by:
getAllin interfaceStorageView- Returns:
- a list of resource amounts
-
getStored
public long getStored()- Specified by:
getStoredin interfaceStorageView- Returns:
- the amount stored
-
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
-
onAddedIntoComposite
Description copied from interface:CompositeAwareChildCalled by aCompositeStoragewhen thisCompositeAwareChildis added into the composite storage.- Specified by:
onAddedIntoCompositein interfaceCompositeAwareChild- Parameters:
parentComposite- the composite storage that thisCompositeAwareChildis contained in
-
onRemovedFromComposite
Description copied from interface:CompositeAwareChildCalled by aCompositeStoragewhen thisCompositeAwareChildis removed from the composite storage.- Specified by:
onRemovedFromCompositein interfaceCompositeAwareChild- Parameters:
parentComposite- the composite storage that thisCompositeAwareChildis/was contained in
-
compositeInsert
public CompositeAwareChild.Amount compositeInsert(ResourceKey resource, long amount, Action action, Actor actor) Description copied from interface:CompositeAwareChildInserts a resource into a storage.- Specified by:
compositeInsertin interfaceCompositeAwareChild- 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
-
compositeExtract
public CompositeAwareChild.Amount compositeExtract(ResourceKey resource, long amount, Action action, Actor actor) Description copied from interface:CompositeAwareChildExtracts a resource from a storage.- Specified by:
compositeExtractin interfaceCompositeAwareChild- 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
-
onSourceAddedToChild
Description copied from interface:ParentCompositeCalled by theCompositeAwareChildto notify to this parent composite storage that a source has been added.- Specified by:
onSourceAddedToChildin interfaceParentComposite- Parameters:
source- the source
-
onSourceRemovedFromChild
Description copied from interface:ParentCompositeCalled by theCompositeAwareChildto notify to this parent composite storage that a source has been removed.- Specified by:
onSourceRemovedFromChildin interfaceParentComposite- Parameters:
source- the source
-
addToCache
Description copied from interface:ParentCompositeAdds a resource to the composite storage cache.- Specified by:
addToCachein interfaceParentComposite- Parameters:
resource- the resourceamount- the amount
-
removeFromCache
Description copied from interface:ParentCompositeRemoves a resource from the composite storage cache.- Specified by:
removeFromCachein interfaceParentComposite- Parameters:
resource- the resourceamount- the amount
-