// Path: src/main/java/org/cyclops/integratedtunnels/api/network/IItemNetwork.java
// public interface IItemNetwork extends IPositionedAddonsNetworkIngredients<ItemStack, Integer> {
// 
// }
// 
// Path: src/main/java/org/cyclops/integratedtunnels/capability/network/ItemNetworkConfig.java
// public class ItemNetworkConfig extends CapabilityConfig<IItemNetwork> {
// 
//     @CapabilityInject(IItemNetwork.class)
//     public static Capability<IItemNetwork> CAPABILITY = null;
// 
//     public ItemNetworkConfig() {
//         super(
//                 CommonCapabilities._instance,
//                 "itemNetwork",
//                 IItemNetwork.class,
//                 new DefaultCapabilityStorage<IItemNetwork>(),
//                 () -> new ItemNetwork(null)
//         );
//     }
// 
// }
// 
// Path: src/main/java/org/cyclops/integratedtunnels/core/part/PartStateRoundRobin.java
// public class PartStateRoundRobin<P extends IPartTypeWriter> extends PartStateWriterBase<P> {
// 
//     private IPartPosIteratorHandler partPosIteratorHandler = null;
// 
//     public PartStateRoundRobin(int inventorySize) {
//         super(inventorySize);
//     }
// 
//     public void setPartPosIteratorHandler(IPartPosIteratorHandler partPosIteratorHandler) {
//         this.partPosIteratorHandler = partPosIteratorHandler;
//     }
// 
//     public IPartPosIteratorHandler getPartPosIteratorHandler() {
//         return partPosIteratorHandler;
//     }
// }
// 
// Path: src/main/java/org/cyclops/integratedtunnels/core/predicate/IngredientPredicate.java
// public abstract class IngredientPredicate<T, M> implements Predicate<T>, ITunnelTransfer {
// 
//     private final IngredientComponent<T, M> ingredientComponent;
//     private final T instance;
//     private final M matchFlags;
//     private final boolean blacklist;
//     private final boolean empty;
//     private final int maxQuantity;
//     private final boolean exactQuantity;
// 
//     public IngredientPredicate(IngredientComponent<T, M> ingredientComponent,
//                                T instance, M matchFlags, boolean blacklist, boolean empty,
//                                int maxQuantity, boolean exactQuantity) {
//         this.ingredientComponent = ingredientComponent;
//         this.instance = instance;
//         this.matchFlags = matchFlags;
//         this.blacklist = blacklist;
//         this.empty = empty;
//         this.maxQuantity = maxQuantity;
//         this.exactQuantity = exactQuantity;
//     }
// 
//     // Note: implementors of this method *should* override equals and hashcode.
//     public IngredientPredicate(IngredientComponent<T, M> ingredientComponent,
//                                boolean blacklist, boolean empty, int maxQuantity, boolean exactQuantity) {
//         this(ingredientComponent, ingredientComponent.getMatcher().getEmptyInstance(), null,
//                 blacklist, empty, maxQuantity, exactQuantity);
//     }
// 
//     public IngredientComponent<T, M> getIngredientComponent() {
//         return ingredientComponent;
//     }
// 
//     @Nonnull
//     public T getInstance() {
//         return instance;
//     }
// 
//     public M getMatchFlags() {
//         return matchFlags;
//     }
// 
//     public boolean hasMatchFlags() {
//         return matchFlags != null && !blacklist;
//     }
// 
//     public boolean isBlacklist() {
//         return blacklist;
//     }
// 
//     public boolean isEmpty() {
//         return empty;
//     }
// 
//     public int getMaxQuantity() {
//         return maxQuantity;
//     }
// 
//     public boolean isExactQuantity() {
//         return exactQuantity;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (!(obj instanceof IngredientPredicate)) {
//             return false;
//         }
//         IngredientPredicate that = (IngredientPredicate) obj;
//         return this.ingredientComponent == that.ingredientComponent
//                 && this.ingredientComponent.getMatcher().matchesExactly(this.instance, (T) that.instance)
//                 && Objects.equals(this.matchFlags, that.matchFlags)
//                 && this.blacklist == that.blacklist
//                 && this.empty == that.empty
//                 && this.maxQuantity == that.maxQuantity
//                 && this.exactQuantity == that.exactQuantity;
//     }
// 
//     @Override
//     public int hashCode() {
//         return ingredientComponent.hashCode()
//                 ^ ingredientComponent.getMatcher().hash(instance)
//                 ^ Objects.hashCode(matchFlags)
//                 ^ (blacklist ? 1 : 0)
//                 ^ (empty ? 2 : 4)
//                 ^ maxQuantity
//                 ^ (exactQuantity ? 8 : 16);
//     }
// 
//     public static enum EmptyBehaviour {
//         ANY,
//         NONE;
// 
//         public static EmptyBehaviour fromBoolean(boolean emptyIsAny) {
//             return emptyIsAny ? ANY : NONE;
//         }
//     }
// }


import net.minecraft.item.ItemStack;
import org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage;
import org.cyclops.integrateddynamics.api.network.INetwork;
import org.cyclops.integrateddynamics.api.part.PartTarget;
import org.cyclops.integrateddynamics.api.part.aspect.property.IAspectProperties;
import org.cyclops.integratedtunnels.api.network.IItemNetwork;
import org.cyclops.integratedtunnels.capability.network.ItemNetworkConfig;
import org.cyclops.integratedtunnels.core.part.PartStateRoundRobin;
import org.cyclops.integratedtunnels.core.predicate.IngredientPredicate;
import javax.annotation.Nullable;
package org.cyclops.integratedtunnels.part.aspect;



/**
 * @author rubensworks
 */
public class ItemTargetStorage extends ChanneledTarget<IItemNetwork, ItemStack> implements IItemTarget {

    private final ITunnelConnection connection;
    private final IIngredientComponentStorage<ItemStack, Integer> storage;
    private final int slot;
    private final IngredientPredicate<ItemStack, Integer> itemStackMatcher;
    private final PartTarget partTarget;
    private final IAspectProperties properties;

    public ItemTargetStorage(ITunnelTransfer transfer, INetwork network,
                             IIngredientComponentStorage<ItemStack, Integer> storage, int slot,
                             IngredientPredicate<ItemStack, Integer> itemStackMatcher, PartTarget partTarget,
// Path: src/main/java/org/cyclops/integratedtunnels/api/network/IItemNetwork.java
// public interface IItemNetwork extends IPositionedAddonsNetworkIngredients<ItemStack, Integer> {
// 
// }
// 
// Path: src/main/java/org/cyclops/integratedtunnels/capability/network/ItemNetworkConfig.java
// public class ItemNetworkConfig extends CapabilityConfig<IItemNetwork> {
// 
//     @CapabilityInject(IItemNetwork.class)
//     public static Capability<IItemNetwork> CAPABILITY = null;
// 
//     public ItemNetworkConfig() {
//         super(
//                 CommonCapabilities._instance,
//                 "itemNetwork",
//                 IItemNetwork.class,
//                 new DefaultCapabilityStorage<IItemNetwork>(),
//                 () -> new ItemNetwork(null)
//         );
//     }
// 
// }
// 
// Path: src/main/java/org/cyclops/integratedtunnels/core/part/PartStateRoundRobin.java
// public class PartStateRoundRobin<P extends IPartTypeWriter> extends PartStateWriterBase<P> {
// 
//     private IPartPosIteratorHandler partPosIteratorHandler = null;
// 
//     public PartStateRoundRobin(int inventorySize) {
//         super(inventorySize);
//     }
// 
//     public void setPartPosIteratorHandler(IPartPosIteratorHandler partPosIteratorHandler) {
//         this.partPosIteratorHandler = partPosIteratorHandler;
//     }
// 
//     public IPartPosIteratorHandler getPartPosIteratorHandler() {
//         return partPosIteratorHandler;
//     }
// }
// 
// Path: src/main/java/org/cyclops/integratedtunnels/core/predicate/IngredientPredicate.java
// public abstract class IngredientPredicate<T, M> implements Predicate<T>, ITunnelTransfer {
// 
//     private final IngredientComponent<T, M> ingredientComponent;
//     private final T instance;
//     private final M matchFlags;
//     private final boolean blacklist;
//     private final boolean empty;
//     private final int maxQuantity;
//     private final boolean exactQuantity;
// 
//     public IngredientPredicate(IngredientComponent<T, M> ingredientComponent,
//                                T instance, M matchFlags, boolean blacklist, boolean empty,
//                                int maxQuantity, boolean exactQuantity) {
//         this.ingredientComponent = ingredientComponent;
//         this.instance = instance;
//         this.matchFlags = matchFlags;
//         this.blacklist = blacklist;
//         this.empty = empty;
//         this.maxQuantity = maxQuantity;
//         this.exactQuantity = exactQuantity;
//     }
// 
//     // Note: implementors of this method *should* override equals and hashcode.
//     public IngredientPredicate(IngredientComponent<T, M> ingredientComponent,
//                                boolean blacklist, boolean empty, int maxQuantity, boolean exactQuantity) {
//         this(ingredientComponent, ingredientComponent.getMatcher().getEmptyInstance(), null,
//                 blacklist, empty, maxQuantity, exactQuantity);
//     }
// 
//     public IngredientComponent<T, M> getIngredientComponent() {
//         return ingredientComponent;
//     }
// 
//     @Nonnull
//     public T getInstance() {
//         return instance;
//     }
// 
//     public M getMatchFlags() {
//         return matchFlags;
//     }
// 
//     public boolean hasMatchFlags() {
//         return matchFlags != null && !blacklist;
//     }
// 
//     public boolean isBlacklist() {
//         return blacklist;
//     }
// 
//     public boolean isEmpty() {
//         return empty;
//     }
// 
//     public int getMaxQuantity() {
//         return maxQuantity;
//     }
// 
//     public boolean isExactQuantity() {
//         return exactQuantity;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (!(obj instanceof IngredientPredicate)) {
//             return false;
//         }
//         IngredientPredicate that = (IngredientPredicate) obj;
//         return this.ingredientComponent == that.ingredientComponent
//                 && this.ingredientComponent.getMatcher().matchesExactly(this.instance, (T) that.instance)
//                 && Objects.equals(this.matchFlags, that.matchFlags)
//                 && this.blacklist == that.blacklist
//                 && this.empty == that.empty
//                 && this.maxQuantity == that.maxQuantity
//                 && this.exactQuantity == that.exactQuantity;
//     }
// 
//     @Override
//     public int hashCode() {
//         return ingredientComponent.hashCode()
//                 ^ ingredientComponent.getMatcher().hash(instance)
//                 ^ Objects.hashCode(matchFlags)
//                 ^ (blacklist ? 1 : 0)
//                 ^ (empty ? 2 : 4)
//                 ^ maxQuantity
//                 ^ (exactQuantity ? 8 : 16);
//     }
// 
//     public static enum EmptyBehaviour {
//         ANY,
//         NONE;
// 
//         public static EmptyBehaviour fromBoolean(boolean emptyIsAny) {
//             return emptyIsAny ? ANY : NONE;
//         }
//     }
// }


// Path: src/main/java/org/cyclops/integratedtunnels/part/aspect/ItemTargetStorage.java
import net.minecraft.item.ItemStack;
import org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage;
import org.cyclops.integrateddynamics.api.network.INetwork;
import org.cyclops.integrateddynamics.api.part.PartTarget;
import org.cyclops.integrateddynamics.api.part.aspect.property.IAspectProperties;
import org.cyclops.integratedtunnels.api.network.IItemNetwork;
import org.cyclops.integratedtunnels.capability.network.ItemNetworkConfig;
import org.cyclops.integratedtunnels.core.part.PartStateRoundRobin;
import org.cyclops.integratedtunnels.core.predicate.IngredientPredicate;
import javax.annotation.Nullable;

package org.cyclops.integratedtunnels.part.aspect;



/**
 * @author rubensworks
 */
public class ItemTargetStorage extends ChanneledTarget<IItemNetwork, ItemStack> implements IItemTarget {

    private final ITunnelConnection connection;
    private final IIngredientComponentStorage<ItemStack, Integer> storage;
    private final int slot;
    private final IngredientPredicate<ItemStack, Integer> itemStackMatcher;
    private final PartTarget partTarget;
    private final IAspectProperties properties;

    public ItemTargetStorage(ITunnelTransfer transfer, INetwork network,
                             IIngredientComponentStorage<ItemStack, Integer> storage, int slot,
                             IngredientPredicate<ItemStack, Integer> itemStackMatcher, PartTarget partTarget,
                             IAspectProperties properties, @Nullable PartStateRoundRobin<?> partState) {