@@ -0,0 +1,1982 @@
+package org.cyclops.cyclopscore.ingredient.collection;%0A%0Aimport org.cyclops.commoncapabilities.api.ingredient.IIngredientMatcher;%0A%0Aimport java.util.Iterator;%0Aimport java.util.NoSuchElementException;%0A%0A/**%0A * An iterator that filters over instances based on an instance with a match condition.%0A * @param %3CT%3E The instance type.%0A * @param %3CM%3E The matching condition parameter.%0A */%0Apublic class FilteredIngredientIterator%3CT, M%3E implements Iterator%3CT%3E %7B%0A%0A    private final Iterator%3CT%3E iterator;%0A    private final IIngredientMatcher%3CT, M%3E matcher;%0A    private final T instance;%0A    private final M matchCondition;%0A%0A    private T next;%0A%0A    /**%0A     * Create a new instance.%0A     * @param iterable An iterable with instances.%0A     * @param matcher A matcher for the type of instances.%0A     * @param instance An instance to match.%0A     * @param matchCondition A match condition to filter by.%0A     */%0A    public FilteredIngredientIterator(Iterable%3CT%3E iterable, IIngredientMatcher%3CT, M%3E matcher,%0A                                      T instance, M matchCondition) %7B%0A        this.iterator = iterable.iterator();%0A        this.matcher = matcher;%0A        this.instance = instance;%0A        this.matchCondition = matchCondition;%0A        this.next = null;%0A    %7D%0A%0A    protected T findNext() %7B%0A        while (iterator.hasNext()) %7B%0A            T next = iterator.next();%0A            if (matcher.matches(instance, next, matchCondition)) %7B%0A                return next;%0A            %7D%0A        %7D%0A        return null;%0A    %7D%0A%0A    @Override%0A    public boolean hasNext() %7B%0A        if (next == null) %7B%0A            this.next = findNext();%0A        %7D%0A        return next != null;%0A    %7D%0A%0A    @Override%0A    public T next() %7B%0A        if (!hasNext()) %7B%0A            throw new NoSuchElementException(%22Tried reading a finished FilteredIngredientIterator%22);%0A        %7D%0A        T next = this.next;%0A        this.next = null;%0A        return next;%0A    %7D%0A%0A    @Override%0A    public void remove() %7B%0A        iterator.remove();%0A    %7D%0A%7D%0A

Add filtered ingredient iterator