Class ResourceRepositoryImpl<T>
java.lang.Object
com.refinedmods.refinedstorage.api.resource.repository.ResourceRepositoryImpl<T>
- All Implemented Interfaces:
ResourceRepository<T>
@API(status=STABLE,
since="2.0.0-milestone.1.0")
public class ResourceRepositoryImpl<T>
extends Object
implements ResourceRepository<T>
-
Constructor Summary
ConstructorsConstructorDescriptionResourceRepositoryImpl(ResourceRepositoryMapper<T> mapper, MutableResourceList backingList, Set<ResourceKey> stickyResources, Function<ResourceRepository<T>, Comparator<T>> identitySortingType, Function<ResourceRepository<T>, Comparator<T>> defaultSortingType) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the backing list and view list.longgetAmount(ResourceKey resource) booleanisSticky(ResourceKey resource) setFilterAndSort(ResourceRepositoryFilter<T> theFilter) voidsetListener(Runnable listener) Sets a listener that is called when the view list changes.booleansetPreventSorting(boolean thePreventSorting) Preventing sorting means that the changes will still arrive at the backing list and view list, but, the view list won't be resorted and if a resource is completely removed, it will stay in the view list until sorting is enabled again.voidsetSort(Comparator<T> theSort, SortingDirection direction) After changing the sort, you still need to callResourceRepository.sort().voidsort()Sorts the view list.voidupdate(ResourceKey resource, long amount) Applies a change to a resource.
-
Constructor Details
-
ResourceRepositoryImpl
public ResourceRepositoryImpl(ResourceRepositoryMapper<T> mapper, MutableResourceList backingList, Set<ResourceKey> stickyResources, Function<ResourceRepository<T>, Comparator<T>> identitySortingType, Function<ResourceRepository<T>, Comparator<T>> defaultSortingType) - Parameters:
mapper- a mapper that transforms resources to the representation in the view listbackingList- the backing liststickyResources- resources which must stay in the view listidentitySortingType- a sorting type required to keep a consistent sorting order with quantity sortingdefaultSortingType- the default sorting type
-
-
Method Details
-
setListener
Description copied from interface:ResourceRepositorySets a listener that is called when the view list changes.- Specified by:
setListenerin interfaceResourceRepository<T>- Parameters:
listener- the listener, can be null
-
setSort
Description copied from interface:ResourceRepositoryAfter changing the sort, you still need to callResourceRepository.sort().- Specified by:
setSortin interfaceResourceRepository<T>- Parameters:
theSort- the sortdirection- the direction
-
setFilterAndSort
- Specified by:
setFilterAndSortin interfaceResourceRepository<T>- Parameters:
theFilter- the filter- Returns:
- the previous filter
-
setPreventSorting
public boolean setPreventSorting(boolean thePreventSorting) Description copied from interface:ResourceRepositoryPreventing sorting means that the changes will still arrive at the backing list and view list, but, the view list won't be resorted and if a resource is completely removed, it will stay in the view list until sorting is enabled again. When disabling prevent sorting, you still need to callResourceRepository.sort().- Specified by:
setPreventSortingin interfaceResourceRepository<T>- Parameters:
thePreventSorting- whether the view should prevent sorting on changes- Returns:
- whether prevent sorting has changed
-
getAmount
- Specified by:
getAmountin interfaceResourceRepository<T>- Parameters:
resource- the resource- Returns:
- the amount in the view, or zero if not present
-
isSticky
- Specified by:
isStickyin interfaceResourceRepository<T>- Parameters:
resource- the resource- Returns:
- whether the resource is sticky
-
sort
public void sort()Description copied from interface:ResourceRepositorySorts the view list. Applies sorting and filtering rules.- Specified by:
sortin interfaceResourceRepository<T>
-
update
Description copied from interface:ResourceRepositoryApplies a change to a resource. Will update the backing list, and will also update the view list (depending on if the view is preventing sorting).- Specified by:
updatein interfaceResourceRepository<T>- Parameters:
resource- the resourceamount- the amount, can be negative or positive, but not zero
-
getViewList
- Specified by:
getViewListin interfaceResourceRepository<T>- Returns:
- the view list
-
copyBackingList
- Specified by:
copyBackingListin interfaceResourceRepository<T>- Returns:
- a copy of the backing list
-
clear
public void clear()Description copied from interface:ResourceRepositoryClears the backing list and view list.- Specified by:
clearin interfaceResourceRepository<T>
-