Class ResourceListImpl

java.lang.Object
com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl
All Implemented Interfaces:
ResourceList

@API(status=STABLE, since="2.0.0-milestone.1.2") public class ResourceListImpl extends Object implements ResourceList
An implementation of a ResourceList that stores the resource entries in memory.
  • Method Details

    • create

      public static ResourceListImpl create()
    • orderPreserving

      public static ResourceListImpl orderPreserving()
    • add

      public ResourceList.OperationResult add(ResourceKey resource, long amount)
      Description copied from interface: ResourceList
      Adds a given resource to the list.
      Specified by:
      add in interface ResourceList
      Parameters:
      resource - the resource, may not be null
      amount - the amount, must be larger than 0
      Returns:
      the result of the operation
    • remove

      public Optional<ResourceList.OperationResult> remove(ResourceKey resource, long amount)
      Description copied from interface: ResourceList
      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 interface ResourceList
      Parameters:
      resource - the resource, may not be null
      amount - the amount, must be larger than 0
      Returns:
      a result if the removal operation was successful, otherwise an empty Optional
    • copyState

      public Collection<ResourceAmount> copyState()
      Description copied from interface: ResourceList
      Retrieves all resources and their amounts from the list.
      Specified by:
      copyState in interface ResourceList
      Returns:
      a list of resource amounts
    • getAll

      public Set<ResourceKey> getAll()
      Specified by:
      getAll in interface ResourceList
      Returns:
      set of resources contained in this list
    • get

      public long get(ResourceKey resource)
      Specified by:
      get in interface ResourceList
      Parameters:
      resource - the resource
      Returns:
      the amount stored, or zero if not stored
    • contains

      public boolean contains(ResourceKey resource)
      Specified by:
      contains in interface ResourceList
      Parameters:
      resource - the resource
      Returns:
      whether the list contains this resource
    • clear

      public void clear()
      Description copied from interface: ResourceList
      Clears the list.
      Specified by:
      clear in interface ResourceList
    • copy

      public ResourceList copy()
      Description copied from interface: ResourceList
      Copies the list.
      Specified by:
      copy in interface ResourceList