Class MutableResourceListImpl
java.lang.Object
com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl
- All Implemented Interfaces:
MutableResourceList
,ResourceList
@API(status=STABLE,
since="2.0.0-milestone.1.2")
public class MutableResourceListImpl
extends Object
implements MutableResourceList
An implementation of a
ResourceList
that stores the resource entries in memory.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.refinedmods.refinedstorage.api.resource.list.MutableResourceList
MutableResourceList.OperationResult
-
Method Summary
Modifier and TypeMethodDescriptionadd
(ResourceKey resource, long amount) Adds a given resource to the list.void
clear()
Clears the list.boolean
contains
(ResourceKey resource) copy()
Copies the list.Retrieves all resources and their amounts from the list.static MutableResourceListImpl
create()
long
get
(ResourceKey resource) getAll()
static MutableResourceListImpl
remove
(ResourceKey resource, long amount) Removes an amount of a certain resource in the list.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.resource.list.MutableResourceList
add, remove
-
Method Details
-
create
-
orderPreserving
-
add
Description copied from interface:MutableResourceList
Adds a given resource to the list.- Specified by:
add
in interfaceMutableResourceList
- Parameters:
resource
- the resource, may not be nullamount
- the amount, must be larger than 0- Returns:
- the result of the operation
-
remove
Description copied from interface:MutableResourceList
Removes an amount of a certain resource in the list. If the amount reaches 0 due to this removal, the resource is removed from the list.- Specified by:
remove
in interfaceMutableResourceList
- Parameters:
resource
- the resource, may not be nullamount
- the amount, must be larger than 0- Returns:
- a result if the removal operation was successful, otherwise an empty
Optional
-
copyState
Description copied from interface:ResourceList
Retrieves all resources and their amounts from the list.- Specified by:
copyState
in interfaceResourceList
- Returns:
- a list of resource amounts
-
getAll
- Specified by:
getAll
in interfaceResourceList
- Returns:
- set of resources contained in this list
-
get
- Specified by:
get
in interfaceResourceList
- Parameters:
resource
- the resource- Returns:
- the amount stored, or zero if not stored
-
contains
- Specified by:
contains
in interfaceResourceList
- Parameters:
resource
- the resource- Returns:
- whether the list contains this resource
-
clear
public void clear()Description copied from interface:MutableResourceList
Clears the list.- Specified by:
clear
in interfaceMutableResourceList
-
copy
Description copied from interface:MutableResourceList
Copies the list.- Specified by:
copy
in interfaceMutableResourceList
-