diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java index e27271244..f6ca770a0 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java @@ -1,8 +1,8 @@ package com.refinedmods.refinedstorage.common.autocrafting; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.common.support.resource.ResourceCodecs; import java.util.ArrayList; @@ -35,13 +35,13 @@ public record ProcessingPatternState( ); List getFlatInputs() { - final ResourceList list = ResourceListImpl.orderPreserving(); + final MutableResourceList list = MutableResourceListImpl.orderPreserving(); inputs.forEach(input -> input.map(Input::input).ifPresent(list::add)); return new ArrayList<>(list.copyState()); } List getFlatOutputs() { - final ResourceList list = ResourceListImpl.orderPreserving(); + final MutableResourceList list = MutableResourceListImpl.orderPreserving(); outputs.forEach(output -> output.ifPresent(list::add)); return new ArrayList<>(list.copyState()); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java index ba95b6e99..880b98f84 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java @@ -3,6 +3,7 @@ import com.refinedmods.refinedstorage.api.grid.view.GridResource; import com.refinedmods.refinedstorage.api.grid.view.GridView; import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import com.refinedmods.refinedstorage.api.resource.list.ResourceList; import com.refinedmods.refinedstorage.common.content.Menus; import com.refinedmods.refinedstorage.common.grid.view.ItemGridResource; @@ -128,13 +129,13 @@ public void clear(final boolean toPlayerInventory) { @API(status = API.Status.INTERNAL) public ResourceList getAvailableListForRecipeTransfer() { - final ResourceList available = getView().copyBackingList(); + final MutableResourceList available = getView().copyBackingList(); addContainerToList(craftingGrid.getCraftingMatrix(), available); addContainerToList(gridPlayer.getInventory(), available); return available; } - private void addContainerToList(final Container container, final ResourceList available) { + private void addContainerToList(final Container container, final MutableResourceList available) { for (int i = 0; i < container.getContainerSize(); ++i) { final ItemStack stack = container.getItem(i); if (stack.isEmpty()) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java index b5f184007..2a3f18d61 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java @@ -2,8 +2,8 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.root.RootStorage; import com.refinedmods.refinedstorage.common.api.storage.PlayerActor; import com.refinedmods.refinedstorage.common.support.RecipeMatrixContainer; @@ -15,8 +15,8 @@ class SnapshotCraftingGridRefillContext implements CraftingGridRefillContext { private final PlayerActor playerActor; private final CraftingGridBlockEntity blockEntity; - private final ResourceList available = ResourceListImpl.create(); - private final ResourceList used = ResourceListImpl.create(); + private final MutableResourceList available = MutableResourceListImpl.create(); + private final MutableResourceList used = MutableResourceListImpl.create(); SnapshotCraftingGridRefillContext( final Player player, diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/ResourceSorters.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/ResourceSorters.java index f70ba6540..bf5ff6516 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/ResourceSorters.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/ResourceSorters.java @@ -3,8 +3,9 @@ import com.refinedmods.refinedstorage.api.network.Network; import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.Comparator; @@ -25,19 +26,20 @@ public static Comparator create(@Nullable final Network network, fi public static Comparator create(@Nullable final Network network, final Inventory playerInventory, final Function resourceExtractor) { - final ResourceList available = ResourceListImpl.create(); + final MutableResourceList available = MutableResourceListImpl.create(); addNetworkItemsIntoList(network, available); addPlayerInventoryItemsIntoList(playerInventory, available); return sortByHighestAvailableFirst(available, resourceExtractor); } - private static void addNetworkItemsIntoList(@Nullable final Network network, final ResourceList list) { + private static void addNetworkItemsIntoList(@Nullable final Network network, final MutableResourceList list) { if (network != null) { network.getComponent(StorageNetworkComponent.class).getAll().forEach(list::add); } } - private static void addPlayerInventoryItemsIntoList(final Inventory playerInventory, final ResourceList list) { + private static void addPlayerInventoryItemsIntoList(final Inventory playerInventory, + final MutableResourceList list) { for (int i = 0; i < playerInventory.getContainerSize(); ++i) { final ItemStack playerInventoryStack = playerInventory.getItem(i); if (playerInventoryStack.isEmpty()) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java index fffbad02c..228a2a8b7 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.network.impl.storage.StorageNetworkComponentImpl; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.common.api.storage.root.FuzzyRootStorage; import com.refinedmods.refinedstorage.common.api.support.resource.list.FuzzyResourceList; import com.refinedmods.refinedstorage.common.support.resource.list.FuzzyResourceListImpl; @@ -13,10 +13,10 @@ public class PlatformStorageNetworkComponent extends StorageNetworkComponentImpl private final FuzzyResourceList fuzzyResourceList; public PlatformStorageNetworkComponent() { - this(new FuzzyResourceListImpl(ResourceListImpl.create())); + this(new FuzzyResourceListImpl(MutableResourceListImpl.create())); } - private PlatformStorageNetworkComponent(final FuzzyResourceList fuzzyResourceList) { + private PlatformStorageNetworkComponent(final FuzzyResourceListImpl fuzzyResourceList) { super(fuzzyResourceList); this.fuzzyResourceList = fuzzyResourceList; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java index 71f2254cf..deeab38ca 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java @@ -1,8 +1,8 @@ package com.refinedmods.refinedstorage.common.support.resource.list; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.AbstractProxyResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.AbstractProxyMutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import com.refinedmods.refinedstorage.common.api.support.resource.FuzzyModeNormalizer; import com.refinedmods.refinedstorage.common.api.support.resource.list.FuzzyResourceList; @@ -14,10 +14,10 @@ import java.util.Optional; import java.util.Set; -public class FuzzyResourceListImpl extends AbstractProxyResourceList implements FuzzyResourceList { +public class FuzzyResourceListImpl extends AbstractProxyMutableResourceList implements FuzzyResourceList { private final Map> normalizedFuzzyMap = new HashMap<>(); - public FuzzyResourceListImpl(final ResourceList delegate) { + public FuzzyResourceListImpl(final MutableResourceList delegate) { super(delegate); } diff --git a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java index 5660e7a86..44110b6f8 100644 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java @@ -1,9 +1,8 @@ package com.refinedmods.refinedstorage.common.support.resource.list; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.common.SetupMinecraft; -import com.refinedmods.refinedstorage.common.api.support.resource.list.FuzzyResourceList; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.Collection; @@ -28,11 +27,11 @@ class FuzzyResourceListImplTest { private static final ItemResource DUMMY_D = new ItemResource(Items.GLASS, DataComponentPatch.EMPTY); private static final ItemResource DUMMY_E = new ItemResource(Items.DARK_OAK_DOOR, DataComponentPatch.EMPTY); - FuzzyResourceList sut; + FuzzyResourceListImpl sut; @BeforeEach void setUp() { - sut = new FuzzyResourceListImpl(ResourceListImpl.create()); + sut = new FuzzyResourceListImpl(MutableResourceListImpl.create()); } @Test diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridView.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridView.java index 0604761f7..c29deb64c 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridView.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridView.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.api.grid.view; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import java.util.List; @@ -100,7 +100,7 @@ public interface GridView { /** * @return a copy of the backing list */ - ResourceList copyBackingList(); + MutableResourceList copyBackingList(); /** * Clears the backing list, view list and tracked resources index. diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewBuilderImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewBuilderImpl.java index 0514a0f54..8bc9c0b13 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewBuilderImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewBuilderImpl.java @@ -1,8 +1,8 @@ package com.refinedmods.refinedstorage.api.grid.view; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import java.util.HashMap; @@ -16,7 +16,7 @@ @API(status = API.Status.STABLE, since = "2.0.0-milestone.2.4") public class GridViewBuilderImpl implements GridViewBuilder { private final GridResourceFactory resourceFactory; - private final ResourceList backingList = ResourceListImpl.create(); + private final MutableResourceList backingList = MutableResourceListImpl.create(); private final Set craftableResources = new HashSet<>(); private final Map trackedResources = new HashMap<>(); private final GridSortingType identitySortingType; diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java index 66e495708..c4b0f4f7f 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.core.CoreValidations; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import java.util.ArrayList; @@ -24,7 +24,7 @@ public class GridViewImpl implements GridView { private static final Logger LOGGER = LoggerFactory.getLogger(GridViewImpl.class); - private final ResourceList backingList; + private final MutableResourceList backingList; private final Comparator identitySort; private final GridResourceFactory resourceFactory; private final Map trackedResources = new HashMap<>(); @@ -47,7 +47,7 @@ public class GridViewImpl implements GridView { * @param craftableResources resources which are craftable and must stay in the view list */ public GridViewImpl(final GridResourceFactory resourceFactory, - final ResourceList backingList, + final MutableResourceList backingList, final Map initialTrackedResources, final Set craftableResources, final GridSortingType identitySortingType, @@ -156,7 +156,7 @@ public void onChange(final ResourceKey resource, final long amount, @Nullable final TrackedResource trackedResource) { final boolean wasAvailable = backingList.contains(resource); - final ResourceList.OperationResult operationResult = updateBackingList(resource, amount); + final MutableResourceList.OperationResult operationResult = updateBackingList(resource, amount); updateOrRemoveTrackedResource(resource, trackedResource); final GridResource gridResource = viewList.index.get(resource); if (gridResource != null) { @@ -172,7 +172,7 @@ public void onChange(final ResourceKey resource, } } - private ResourceList.OperationResult updateBackingList(final ResourceKey resource, final long amount) { + private MutableResourceList.OperationResult updateBackingList(final ResourceKey resource, final long amount) { if (amount < 0) { return backingList.remove(resource, Math.abs(amount)).orElseThrow(RuntimeException::new); } else { @@ -204,7 +204,7 @@ private void reinsertIntoViewList(final ResourceKey resource, final GridResource } private void handleChangeForExistingResource(final ResourceKey resource, - final ResourceList.OperationResult operationResult, + final MutableResourceList.OperationResult operationResult, final GridResource gridResource) { final boolean noLongerAvailable = !operationResult.available(); final boolean canBeSorted = !preventSorting; @@ -283,7 +283,7 @@ public List getViewList() { } @Override - public ResourceList copyBackingList() { + public MutableResourceList copyBackingList() { return backingList.copy(); } diff --git a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImplTest.java b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImplTest.java index 3803ecf02..254269cfb 100644 --- a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImplTest.java +++ b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImplTest.java @@ -6,7 +6,7 @@ import com.refinedmods.refinedstorage.api.grid.view.GridResourceImpl; import com.refinedmods.refinedstorage.api.grid.view.GridView; import com.refinedmods.refinedstorage.api.grid.view.GridViewImpl; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import com.refinedmods.refinedstorage.query.lexer.LexerTokenMappings; import com.refinedmods.refinedstorage.query.parser.ParserOperatorMappings; @@ -35,7 +35,7 @@ class GridQueryParserImplTest { private final GridView view = new GridViewImpl( (resource, craftable) -> Optional.of(new GridResourceImpl(resource)), - ResourceListImpl.create(), + MutableResourceListImpl.create(), new HashMap<>(), new HashSet<>(), v -> Comparator.comparing(GridResource::getName), diff --git a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/GameTestUtil.java b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/GameTestUtil.java index 99c8eb53f..09b901952 100644 --- a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/GameTestUtil.java +++ b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/GameTestUtil.java @@ -6,8 +6,9 @@ import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.api.storage.EmptyActor; import com.refinedmods.refinedstorage.common.api.support.network.AbstractNetworkNodeContainerBlockEntity; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainer; @@ -238,7 +239,7 @@ private static Runnable resourceContainerContainsExactly(final ResourceContainer final ResourceAmount... expected) { final ResourceList expectedList = toResourceList(expected); return () -> { - final ResourceList given = ResourceListImpl.create(); + final MutableResourceList given = MutableResourceListImpl.create(); for (int i = 0; i < container.size(); i++) { final ResourceAmount item = container.get(i); if (item != null) { @@ -255,7 +256,7 @@ public static Runnable containerContainsExactly(final GameTestHelper helper, final var containerBlockEntity = requireBlockEntity(helper, pos, BaseContainerBlockEntity.class); final ResourceList expectedList = toResourceList(expected); return () -> { - final ResourceList given = ResourceListImpl.create(); + final MutableResourceList given = MutableResourceListImpl.create(); for (int i = 0; i < containerBlockEntity.getContainerSize(); i++) { final ItemStack itemStack = containerBlockEntity.getItem(i); if (!itemStack.isEmpty()) { @@ -281,7 +282,7 @@ private static ResourceList toResourceList(final ResourceAmount... resources) { } private static ResourceList toResourceList(final Collection resources) { - final ResourceList list = ResourceListImpl.create(); + final MutableResourceList list = MutableResourceListImpl.create(); for (final ResourceAmount resource : resources) { list.add(resource); } diff --git a/refinedstorage-network-test/src/main/java/com/refinedmods/refinedstorage/network/test/NetworkTestFixtures.java b/refinedstorage-network-test/src/main/java/com/refinedmods/refinedstorage/network/test/NetworkTestFixtures.java index 2ad303b6c..3d79eb28f 100644 --- a/refinedstorage-network-test/src/main/java/com/refinedmods/refinedstorage/network/test/NetworkTestFixtures.java +++ b/refinedstorage-network-test/src/main/java/com/refinedmods/refinedstorage/network/test/NetworkTestFixtures.java @@ -15,7 +15,7 @@ import com.refinedmods.refinedstorage.api.network.security.SecurityNetworkComponent; import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.network.test.fake.FakePermissions; public final class NetworkTestFixtures { @@ -33,7 +33,7 @@ public final class NetworkTestFixtures { ); NETWORK_COMPONENT_MAP_FACTORY.addFactory( StorageNetworkComponent.class, - network -> new StorageNetworkComponentImpl(ResourceListImpl.orderPreserving()) + network -> new StorageNetworkComponentImpl(MutableResourceListImpl.orderPreserving()) ); NETWORK_COMPONENT_MAP_FACTORY.addFactory( SecurityNetworkComponent.class, diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java index 90674582f..836b1001a 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java @@ -6,7 +6,7 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.resource.filter.Filter; import com.refinedmods.refinedstorage.api.resource.filter.FilterMode; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import com.refinedmods.refinedstorage.api.resource.list.listenable.ResourceListListener; import com.refinedmods.refinedstorage.api.storage.AccessMode; import com.refinedmods.refinedstorage.api.storage.Actor; @@ -159,7 +159,7 @@ public long getStored() { } @Override - public void onChanged(final ResourceList.OperationResult change) { + public void onChanged(final MutableResourceList.OperationResult change) { if (delegate != null && delegate.contains(delegate)) { return; } diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/ExposedStorage.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/ExposedStorage.java index 0d9987cbb..4ad3e8bf7 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/ExposedStorage.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/ExposedStorage.java @@ -3,7 +3,7 @@ import com.refinedmods.refinedstorage.api.network.impl.storage.AbstractImmutableConfiguredProxyStorage; import com.refinedmods.refinedstorage.api.network.impl.storage.StorageConfiguration; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.Storage; import com.refinedmods.refinedstorage.api.storage.composite.CompositeStorage; @@ -17,7 +17,7 @@ class ExposedStorage extends AbstractImmutableConfiguredProxyStorage implements CompositeStorage { protected ExposedStorage(final StorageConfiguration config) { - super(config, new CompositeStorageImpl(ResourceListImpl.create())); + super(config, new CompositeStorageImpl(MutableResourceListImpl.create())); } long getCapacity() { diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImpl.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImpl.java index 1d4babcbb..af09e3b44 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImpl.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImpl.java @@ -3,7 +3,7 @@ import com.refinedmods.refinedstorage.api.network.node.container.NetworkNodeContainer; import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.network.storage.StorageProvider; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.Storage; import com.refinedmods.refinedstorage.api.storage.TrackedResourceAmount; @@ -17,7 +17,7 @@ public class StorageNetworkComponentImpl extends RootStorageImpl implements StorageNetworkComponent { private static final Logger LOGGER = LoggerFactory.getLogger(StorageNetworkComponentImpl.class); - public StorageNetworkComponentImpl(final ResourceList list) { + public StorageNetworkComponentImpl(final MutableResourceList list) { super(list); } diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNodeTest.java index 685591a0d..782b0d833 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNodeTest.java @@ -6,7 +6,7 @@ import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.resource.filter.FilterMode; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.EmptyActor; import com.refinedmods.refinedstorage.api.storage.Storage; @@ -56,7 +56,7 @@ void shouldNotTransferWithoutNetwork(@InjectNetworkStorageComponent final Storag // Arrange networkStorage.addSource(new StorageImpl()); - final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(MutableResourceListImpl.orderPreserving()); source.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source); @@ -77,7 +77,7 @@ void shouldNotTransferWhenInactive(@InjectNetworkStorageComponent final StorageN // Arrange networkStorage.addSource(new StorageImpl()); - final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(MutableResourceListImpl.orderPreserving()); source.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source); @@ -139,14 +139,14 @@ public long extract(final ResourceKey resource, source0.insert(A, 1, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source0); - final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 35, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source1); - final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(2, source2); @@ -180,14 +180,14 @@ void shouldInsertAllowlist(@InjectNetworkStorageComponent final StorageNetworkCo // Arrange networkStorage.addSource(new StorageImpl()); - final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 35, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set((sut.getSize() / 2) - 2, source1); - final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set((sut.getSize() / 2) - 1, source2); @@ -219,14 +219,14 @@ void shouldInsertBlocklist(@InjectNetworkStorageComponent final StorageNetworkCo // Arrange networkStorage.addSource(new StorageImpl()); - final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 35, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source1); - final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -277,7 +277,7 @@ void shouldNotifyListenerWhenReadyInsertingAllResources( // Arrange networkStorage.addSource(new StorageImpl()); - final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(MutableResourceListImpl.orderPreserving()); source.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); @@ -297,12 +297,12 @@ void shouldNotifyListenerWhenReadyInsertingAllResources( @Test void shouldNotifyListenerWhenReadyInsertingAllResourcesAndUsingFilterButInsertedNothing() { // Arrange - final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source1); - final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -332,13 +332,13 @@ void shouldNotifyListenerWhenReadyInsertingAllResourcesAndUsingFilterButStillIns // Arrange networkStorage.addSource(new StorageImpl()); - final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source1); - final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -368,14 +368,14 @@ void shouldNotNotifyListenerWhenReadyInsertingAllResourcesAndNetworkIsFull( // Arrange networkStorage.addSource(new LimitedStorageImpl(15)); - final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source1); - final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(MutableResourceListImpl.orderPreserving()); source2.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -596,12 +596,12 @@ void shouldNotifyListenerWhenReadyExtractingAllResourcesAndUsingFilterButStillEx @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new StorageImpl(ResourceListImpl.orderPreserving())); + networkStorage.addSource(new StorageImpl(MutableResourceListImpl.orderPreserving())); networkStorage.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(MutableResourceListImpl.orderPreserving()); provider.set(0, source); sut.setProvider(provider); @@ -662,7 +662,7 @@ void shouldRespectNormalizer( // Arrange networkStorage.addSource(new StorageImpl()); - final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(MutableResourceListImpl.orderPreserving()); source.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source.insert(A_ALTERNATIVE, 5, Action.EXECUTE, EmptyActor.INSTANCE); source.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImplTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImplTest.java index c79cc9c67..4e5784a06 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImplTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImplTest.java @@ -6,7 +6,7 @@ import com.refinedmods.refinedstorage.api.network.node.container.NetworkNodeContainer; import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.EmptyActor; import com.refinedmods.refinedstorage.api.storage.TrackedResourceAmount; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; @@ -37,7 +37,7 @@ class StorageNetworkComponentImplTest { @BeforeEach void setUp() { - sut = new StorageNetworkComponentImpl(ResourceListImpl.create()); + sut = new StorageNetworkComponentImpl(MutableResourceListImpl.create()); storage1 = new StorageNetworkNode(0, 0, 1); storage1.setNetwork(new NetworkImpl(NetworkTestFixtures.NETWORK_COMPONENT_MAP_FACTORY)); diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyMutableResourceList.java similarity index 79% rename from refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java rename to refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyMutableResourceList.java index a4df54f02..2a4871b5a 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyMutableResourceList.java @@ -10,13 +10,13 @@ import org.apiguardian.api.API; /** - * This is a utility class to easily decorate a {@link ResourceList}. + * This is a utility class to easily decorate a {@link MutableResourceListImpl}. */ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") -public abstract class AbstractProxyResourceList implements ResourceList { - private final ResourceList delegate; +public abstract class AbstractProxyMutableResourceList implements MutableResourceList { + private final MutableResourceList delegate; - protected AbstractProxyResourceList(final ResourceList delegate) { + protected AbstractProxyMutableResourceList(final MutableResourceList delegate) { this.delegate = delegate; } @@ -51,7 +51,7 @@ public Set getAll() { } @Override - public ResourceList copy() { + public MutableResourceList copy() { return delegate.copy(); } diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/MutableResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/MutableResourceList.java new file mode 100644 index 000000000..324bc5a10 --- /dev/null +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/MutableResourceList.java @@ -0,0 +1,79 @@ +package com.refinedmods.refinedstorage.api.resource.list; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; + +import java.util.Optional; + +import org.apiguardian.api.API; + +/** + * Mutable variant of {@link ResourceList}. + * Implementation can be found in {@link MutableResourceListImpl}. + */ +@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") +public interface MutableResourceList extends ResourceList { + /** + * Adds a given resource to the list. + * + * @param resource the resource, may not be null + * @param amount the amount, must be larger than 0 + * @return the result of the operation + */ + OperationResult add(ResourceKey resource, long amount); + + /** + * Adds a given resource to the list. + * Shorthand for {@link #add(ResourceKey, long)}. + * + * @param resourceAmount the resource and the amount + * @return the result of the operation + */ + default OperationResult add(ResourceAmount resourceAmount) { + return add(resourceAmount.resource(), resourceAmount.amount()); + } + + /** + * 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. + * + * @param resource the resource, may not be null + * @param amount the amount, must be larger than 0 + * @return a result if the removal operation was successful, otherwise an empty {@link Optional} + */ + Optional remove(ResourceKey resource, long amount); + + /** + * 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. + * Shorthand for {@link #remove(ResourceKey, long)}. + * + * @param resourceAmount the resource and the amount + * @return a result if the removal operation was successful, otherwise an empty {@link Optional} + */ + default Optional remove(ResourceAmount resourceAmount) { + return remove(resourceAmount.resource(), resourceAmount.amount()); + } + + /** + * Clears the list. + */ + void clear(); + + /** + * Copies the list. + */ + MutableResourceList copy(); + + /** + * Represents the result of an operation in a {@link MutableResourceList}. + * + * @param resource the resource affected by the operation + * @param amount the current amount in the list + * @param change the delta caused by the operation + * @param available whether this resource is still available in the list, or if it was removed + */ + @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") + record OperationResult(ResourceKey resource, long amount, long change, boolean available) { + } +} diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/MutableResourceListImpl.java similarity index 89% rename from refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java rename to refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/MutableResourceListImpl.java index c47cc8be0..12b6b0131 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/MutableResourceListImpl.java @@ -17,19 +17,19 @@ * An implementation of a {@link ResourceList} that stores the resource entries in memory. */ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") -public class ResourceListImpl implements ResourceList { +public class MutableResourceListImpl implements MutableResourceList { private final Map entries; - private ResourceListImpl(final Map entries) { + private MutableResourceListImpl(final Map entries) { this.entries = entries; } - public static ResourceListImpl create() { - return new ResourceListImpl(new HashMap<>()); + public static MutableResourceListImpl create() { + return new MutableResourceListImpl(new HashMap<>()); } - public static ResourceListImpl orderPreserving() { - return new ResourceListImpl(new LinkedHashMap<>()); + public static MutableResourceListImpl orderPreserving() { + return new MutableResourceListImpl(new LinkedHashMap<>()); } @Override @@ -110,8 +110,8 @@ public void clear() { } @Override - public ResourceList copy() { - final ResourceList copy = ResourceListImpl.create(); + public MutableResourceList copy() { + final MutableResourceList copy = MutableResourceListImpl.create(); entries.forEach((key, entry) -> copy.add(key, entry.amount)); return copy; } diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java index 44f86eaf3..cb87809b4 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java @@ -4,59 +4,15 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import java.util.Collection; -import java.util.Optional; import java.util.Set; import org.apiguardian.api.API; /** - * Represents a list of a resource of an arbitrary type. - * A basic implementation of this class can be found in {@link ResourceListImpl}. + * Represents a list of resources of an arbitrary type. */ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") public interface ResourceList { - /** - * Adds a given resource to the list. - * - * @param resource the resource, may not be null - * @param amount the amount, must be larger than 0 - * @return the result of the operation - */ - OperationResult add(ResourceKey resource, long amount); - - /** - * Adds a given resource to the list. - * Shorthand for {@link #add(ResourceKey, long)}. - * - * @param resourceAmount the resource and the amount - * @return the result of the operation - */ - default OperationResult add(ResourceAmount resourceAmount) { - return add(resourceAmount.resource(), resourceAmount.amount()); - } - - /** - * 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. - * - * @param resource the resource, may not be null - * @param amount the amount, must be larger than 0 - * @return a result if the removal operation was successful, otherwise an empty {@link Optional} - */ - Optional remove(ResourceKey resource, long amount); - - /** - * 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. - * Shorthand for {@link #remove(ResourceKey, long)}. - * - * @param resourceAmount the resource and the amount - * @return a result if the removal operation was successful, otherwise an empty {@link Optional} - */ - default Optional remove(ResourceAmount resourceAmount) { - return remove(resourceAmount.resource(), resourceAmount.amount()); - } - /** * Retrieves all resources and their amounts from the list. * @@ -80,26 +36,4 @@ default Optional remove(ResourceAmount resourceAmount) { * @return whether the list contains this resource */ boolean contains(ResourceKey resource); - - /** - * Clears the list. - */ - void clear(); - - /** - * Copies the list. - */ - ResourceList copy(); - - /** - * Represents the result of an operation in a {@link ResourceList}. - * - * @param resource the resource affected by the operation - * @param amount teh current amount in the list - * @param change the delta caused by the operation - * @param available whether this resource is still available in the list, or if it was removed - */ - @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") - record OperationResult(ResourceKey resource, long amount, long change, boolean available) { - } } diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceList.java index 91adadfb2..a76c5c911 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceList.java @@ -1,8 +1,8 @@ package com.refinedmods.refinedstorage.api.resource.list.listenable; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.AbstractProxyResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.AbstractProxyMutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import java.util.HashSet; import java.util.Optional; @@ -17,10 +17,10 @@ * is being performed through this list, not the delegate list. */ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") -public class ListenableResourceList extends AbstractProxyResourceList { +public class ListenableResourceList extends AbstractProxyMutableResourceList { private final Set listeners = new HashSet<>(); - public ListenableResourceList(final ResourceList delegate) { + public ListenableResourceList(final MutableResourceList delegate) { super(delegate); } diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ResourceListListener.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ResourceListListener.java index 47be7f4bf..e428a151c 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ResourceListListener.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ResourceListListener.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.api.resource.list.listenable; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import org.apiguardian.api.API; @@ -15,5 +15,5 @@ public interface ResourceListListener { * * @param change the change */ - void onChanged(ResourceList.OperationResult change); + void onChanged(MutableResourceList.OperationResult change); } diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractMutableResourceListTest.java similarity index 89% rename from refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java rename to refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractMutableResourceListTest.java index 2ed6f703c..2d288e496 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractMutableResourceListTest.java @@ -14,20 +14,20 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -abstract class AbstractResourceListTest { - private ResourceList list; +abstract class AbstractMutableResourceListTest { + private MutableResourceList list; @BeforeEach void setUp() { list = createList(); } - protected abstract ResourceList createList(); + protected abstract MutableResourceList createList(); @Test void shouldAddNewResource() { // Act - final ResourceList.OperationResult result = list.add(TestResource.A, 10); + final MutableResourceList.OperationResult result = list.add(TestResource.A, 10); // Assert assertThat(result.change()).isEqualTo(10); @@ -47,7 +47,7 @@ void shouldAddNewResource() { @Test void shouldAddNewResourceWithResourceAmountDirectly() { // Act - final ResourceList.OperationResult result = list.add(new ResourceAmount(TestResource.A, 10)); + final MutableResourceList.OperationResult result = list.add(new ResourceAmount(TestResource.A, 10)); // Assert assertThat(result.change()).isEqualTo(10); @@ -67,8 +67,8 @@ void shouldAddNewResourceWithResourceAmountDirectly() { @Test void shouldAddMultipleOfSameResource() { // Act - final ResourceList.OperationResult result1 = list.add(TestResource.A, 10); - final ResourceList.OperationResult result2 = list.add(TestResource.A, 5); + final MutableResourceList.OperationResult result1 = list.add(TestResource.A, 10); + final MutableResourceList.OperationResult result2 = list.add(TestResource.A, 5); // Assert assertThat(result1.change()).isEqualTo(10); @@ -93,9 +93,9 @@ void shouldAddMultipleOfSameResource() { @Test void shouldAddMultipleOfDifferentResources() { // Act - final ResourceList.OperationResult result1 = list.add(TestResource.A, 10); - final ResourceList.OperationResult result2 = list.add(TestResource.A, 5); - final ResourceList.OperationResult result3 = list.add(TestResource.B, 3); + final MutableResourceList.OperationResult result1 = list.add(TestResource.A, 10); + final MutableResourceList.OperationResult result2 = list.add(TestResource.A, 5); + final MutableResourceList.OperationResult result3 = list.add(TestResource.B, 3); // Assert assertThat(result1.change()).isEqualTo(10); @@ -142,7 +142,7 @@ void shouldNotAddInvalidResourceOrAmount() { @Test void shouldNotRemoveResourceWhenItIsNotAvailable() { // Act - final Optional result = list.remove(TestResource.A, 10); + final Optional result = list.remove(TestResource.A, 10); // Assert assertThat(result).isEmpty(); @@ -155,7 +155,7 @@ void shouldRemoveResourcePartly() { list.add(TestResource.B, 6); // Act - final Optional result2 = list.remove(TestResource.A, 5); + final Optional result2 = list.remove(TestResource.A, 5); // Assert assertThat(result2).isPresent(); @@ -184,7 +184,7 @@ void shouldRemoveResourcePartlyWithResourceAmountDirectly() { list.add(TestResource.B, 6); // Act - final Optional result2 = list.remove(new ResourceAmount( + final Optional result2 = list.remove(new ResourceAmount( TestResource.A, 5 )); @@ -216,7 +216,7 @@ void shouldRemoveResourceCompletely() { list.add(TestResource.B, 6); // Act - final Optional result = list.remove(TestResource.A, 20); + final Optional result = list.remove(TestResource.A, 20); // Assert assertThat(result).isPresent(); @@ -244,7 +244,7 @@ void shouldRemoveResourceCompletelyWithResourceAmountDirectly() { list.add(TestResource.B, 6); // Act - final Optional result2 = list.remove(new ResourceAmount( + final Optional result2 = list.remove(new ResourceAmount( TestResource.A, 20 )); @@ -275,7 +275,7 @@ void shouldNotRemoveResourceWithMoreThanIsAvailable() { list.add(TestResource.B, 6); // Act - final Optional result = list.remove(TestResource.A, 21); + final Optional result = list.remove(TestResource.A, 21); // Assert assertThat(result).isPresent(); @@ -340,7 +340,7 @@ void shouldCopyList() { list.add(TestResource.B, 5); // Act - final ResourceList copy = list.copy(); + final MutableResourceList copy = list.copy(); list.add(TestResource.A, 1); list.add(TestResource.C, 3); diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/MutableResourceListImplTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/MutableResourceListImplTest.java new file mode 100644 index 000000000..1a7a937a4 --- /dev/null +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/MutableResourceListImplTest.java @@ -0,0 +1,8 @@ +package com.refinedmods.refinedstorage.api.resource.list; + +class MutableResourceListImplTest extends AbstractMutableResourceListTest { + @Override + protected MutableResourceList createList() { + return MutableResourceListImpl.create(); + } +} diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ProxyResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ProxyResourceListTest.java index fb0f9aa52..637d8936f 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ProxyResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ProxyResourceListTest.java @@ -1,9 +1,9 @@ package com.refinedmods.refinedstorage.api.resource.list; -class ProxyResourceListTest extends AbstractResourceListTest { +class ProxyResourceListTest extends AbstractMutableResourceListTest { @Override - protected ResourceList createList() { - return new AbstractProxyResourceList(ResourceListImpl.create()) { + protected MutableResourceList createList() { + return new AbstractProxyMutableResourceList(MutableResourceListImpl.create()) { }; } } diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImplTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImplTest.java deleted file mode 100644 index f8c1259ca..000000000 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImplTest.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.refinedmods.refinedstorage.api.resource.list; - -class ResourceListImplTest extends AbstractResourceListTest { - @Override - protected ResourceList createList() { - return ResourceListImpl.create(); - } -} diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java index 4cf2d9393..2f4094cae 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java @@ -1,8 +1,8 @@ package com.refinedmods.refinedstorage.api.resource.list.listenable; import com.refinedmods.refinedstorage.api.resource.TestResource; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import java.util.ArrayList; import java.util.List; @@ -15,13 +15,13 @@ class ListenableResourceListTest { private FakeResourceListListener listener; - private ResourceListImpl list; + private MutableResourceListImpl list; private ListenableResourceList sut; @BeforeEach void setUp() { listener = new FakeResourceListListener(); - list = ResourceListImpl.create(); + list = MutableResourceListImpl.create(); sut = new ListenableResourceList(list); } @@ -31,7 +31,7 @@ void shouldCallListenerWhenAdding() { sut.addListener(listener); // Act - final ResourceList.OperationResult result = sut.add(TestResource.A, 10); + final MutableResourceList.OperationResult result = sut.add(TestResource.A, 10); // Assert assertThat(result.change()).isEqualTo(10); @@ -44,7 +44,7 @@ void shouldCallListenerWhenAdding() { @Test void shouldNotCallListenerWhenAddingWithoutListener() { // Act - final ResourceList.OperationResult result = sut.add(TestResource.A, 10); + final MutableResourceList.OperationResult result = sut.add(TestResource.A, 10); // Assert assertThat(result.change()).isEqualTo(10); @@ -61,7 +61,7 @@ void shouldCallListenerWhenRemoving() { sut.add(TestResource.A, 10); // Act - final Optional result = sut.remove(TestResource.A, 10); + final Optional result = sut.remove(TestResource.A, 10); // Assert assertThat(result).isPresent(); @@ -78,7 +78,7 @@ void shouldNotCallListenerWhenRemovingWithoutListener() { sut.add(TestResource.A, 10); // Act - final Optional result = sut.remove(TestResource.A, 10); + final Optional result = sut.remove(TestResource.A, 10); // Assert assertThat(result).isPresent(); @@ -96,7 +96,7 @@ void shouldNotCallListenerWhenRemovingWithoutResult() { sut.add(TestResource.A, 10); // Act - final Optional result = sut.remove(TestResource.B, 10); + final Optional result = sut.remove(TestResource.B, 10); // Assert assertThat(result).isEmpty(); @@ -130,10 +130,10 @@ void shouldBeAbleToRemoveListener() { } private static class FakeResourceListListener implements ResourceListListener { - private final List changes = new ArrayList<>(); + private final List changes = new ArrayList<>(); @Override - public void onChanged(final ResourceList.OperationResult change) { + public void onChanged(final MutableResourceList.OperationResult change) { changes.add(change); } } diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/StorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/StorageImpl.java index d82909000..358e14d20 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/StorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/StorageImpl.java @@ -3,8 +3,8 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import java.util.Collection; @@ -15,15 +15,15 @@ */ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0") public class StorageImpl implements Storage { - private final ResourceList list; + private final MutableResourceList list; private long stored; - public StorageImpl(final ResourceList list) { + public StorageImpl(final MutableResourceList list) { this.list = list; } public StorageImpl() { - this(ResourceListImpl.create()); + this(MutableResourceListImpl.create()); } @Override diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java index 829ba79bd..8bd73f4a3 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java @@ -3,7 +3,7 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.Storage; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; @@ -26,13 +26,13 @@ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0") public class CompositeStorageImpl implements CompositeStorage, CompositeAwareChild, ParentComposite { private final List sources = new ArrayList<>(); - private final ResourceList list; + private final MutableResourceList list; private final Set parentComposites = new HashSet<>(); /** * @param list the backing list of this composite storage, used to retrieve a view of the sources */ - public CompositeStorageImpl(final ResourceList list) { + public CompositeStorageImpl(final MutableResourceList list) { this.list = list; } diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java index 5e063794a..d61e737ae 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java @@ -3,8 +3,9 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.composite.CompositeAwareChild; import com.refinedmods.refinedstorage.api.storage.composite.ParentComposite; @@ -19,7 +20,7 @@ public class ExternalStorage implements CompositeAwareChild { private final ExternalStorageProvider provider; private final Set parents = new HashSet<>(); - private final ResourceList cache = ResourceListImpl.create(); + private final MutableResourceList cache = MutableResourceListImpl.create(); private final ExternalStorageListener listener; public ExternalStorage(final ExternalStorageProvider provider, final ExternalStorageListener listener) { @@ -116,7 +117,7 @@ private void removeFromCache(final ResourceKey resource, final long amount) { } private ResourceList buildCache() { - final ResourceList list = ResourceListImpl.create(); + final MutableResourceList list = MutableResourceListImpl.create(); provider.iterator().forEachRemaining(list::add); return list; } diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java index b85e38871..f993c9b41 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java @@ -3,8 +3,8 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.resource.list.listenable.ListenableResourceList; import com.refinedmods.refinedstorage.api.resource.list.listenable.ResourceListListener; import com.refinedmods.refinedstorage.api.storage.Actor; @@ -24,10 +24,10 @@ public class RootStorageImpl implements RootStorage { private final ListenableResourceList list; public RootStorageImpl() { - this(ResourceListImpl.create()); + this(MutableResourceListImpl.create()); } - public RootStorageImpl(final ResourceList list) { + public RootStorageImpl(final MutableResourceList list) { this.list = new ListenableResourceList(list); this.storage = new CompositeStorageImpl(this.list); } diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImplTest.java index 985ca196a..a3875a85e 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImplTest.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.EmptyActor; import com.refinedmods.refinedstorage.api.storage.FakeActors; import com.refinedmods.refinedstorage.api.storage.Storage; @@ -27,7 +27,7 @@ class CompositeStorageImplTest { @BeforeEach void setUp() { - sut = new CompositeStorageImpl(ResourceListImpl.create()); + sut = new CompositeStorageImpl(MutableResourceListImpl.create()); } @Test diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/ExtractCompositeStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/ExtractCompositeStorageImplTest.java index b5d12bf59..45227e855 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/ExtractCompositeStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/ExtractCompositeStorageImplTest.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.ActorCapturingStorage; import com.refinedmods.refinedstorage.api.storage.EmptyActor; @@ -23,7 +23,7 @@ class ExtractCompositeStorageImplTest { @BeforeEach void setUp() { - sut = new CompositeStorageImpl(ResourceListImpl.create()); + sut = new CompositeStorageImpl(MutableResourceListImpl.create()); } @ParameterizedTest diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/InsertCompositeStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/InsertCompositeStorageImplTest.java index 6dab1918f..076d100a0 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/InsertCompositeStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/InsertCompositeStorageImplTest.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.ActorCapturingStorage; import com.refinedmods.refinedstorage.api.storage.EmptyActor; @@ -22,7 +22,7 @@ class InsertCompositeStorageImplTest { @BeforeEach void setUp() { - sut = new CompositeStorageImpl(ResourceListImpl.create()); + sut = new CompositeStorageImpl(MutableResourceListImpl.create()); } @ParameterizedTest diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/SubCompositeCompositeStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/SubCompositeCompositeStorageImplTest.java index fc051b6b1..0d17e84f1 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/SubCompositeCompositeStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/SubCompositeCompositeStorageImplTest.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; import com.refinedmods.refinedstorage.api.storage.EmptyActor; import com.refinedmods.refinedstorage.api.storage.Storage; import com.refinedmods.refinedstorage.api.storage.StorageImpl; @@ -19,13 +19,13 @@ class SubCompositeCompositeStorageImplTest { @BeforeEach void setUp() { - sut = new CompositeStorageImpl(ResourceListImpl.create()); + sut = new CompositeStorageImpl(MutableResourceListImpl.create()); } @Test void testAddingSubCompositeShouldAddAllResourcesToParent() { // Arrange - final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); + final CompositeStorage subComposite = new CompositeStorageImpl(MutableResourceListImpl.create()); subComposite.addSource(new StorageImpl()); subComposite.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); @@ -41,7 +41,7 @@ void testAddingSubCompositeShouldAddAllResourcesToParent() { @Test void testRemovingSubCompositeShouldRemoveAllResourcesFromParent() { // Arrange - final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); + final CompositeStorage subComposite = new CompositeStorageImpl(MutableResourceListImpl.create()); subComposite.addSource(new StorageImpl()); subComposite.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); @@ -62,7 +62,7 @@ void testRemovingSubCompositeShouldRemoveAllResourcesFromParent() { @Test void testAddingSourceToSubCompositeShouldNotifyParent() { // Arrange - final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); + final CompositeStorage subComposite = new CompositeStorageImpl(MutableResourceListImpl.create()); final Storage subStorage = new StorageImpl(); subStorage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); @@ -89,7 +89,7 @@ void testAddingSourceToSubCompositeShouldNotifyParent() { @Test void testRemovingSourceFromSubCompositeShouldNotifyParent() { // Arrange - final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); + final CompositeStorage subComposite = new CompositeStorageImpl(MutableResourceListImpl.create()); final Storage subStorage = new StorageImpl(); subStorage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java index da1362897..a8ae7cba2 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; import com.refinedmods.refinedstorage.api.resource.list.listenable.ResourceListListener; import com.refinedmods.refinedstorage.api.storage.EmptyActor; import com.refinedmods.refinedstorage.api.storage.Storage; @@ -104,7 +104,7 @@ void shouldCallListenerOnInsertion(final Action action) { final ResourceListListener listener = mock(ResourceListListener.class); sut.addListener(listener); - final var changedResource = ArgumentCaptor.forClass(ResourceList.OperationResult.class); + final var changedResource = ArgumentCaptor.forClass(MutableResourceList.OperationResult.class); // Act sut.insert(A, 8, action, EmptyActor.INSTANCE); @@ -134,7 +134,7 @@ void shouldCallListenerOnExtraction(final Action action) { final ResourceListListener listener = mock(ResourceListListener.class); sut.addListener(listener); - final var changedResource = ArgumentCaptor.forClass(ResourceList.OperationResult.class); + final var changedResource = ArgumentCaptor.forClass(MutableResourceList.OperationResult.class); // Act sut.extract(A, 5, action, EmptyActor.INSTANCE);