org.infinispan.commons.util.RemovableCloseableIterator Maven / Gradle / Ivy
package org.infinispan.commons.util;
import java.util.function.Consumer;
/**
* A CloseableIterator implementation that allows for a CloseableIterator that doesn't allow remove operations to
* implement remove by delegating the call to the provided consumer to remove the previously read value.
*
* @author wburns
* @since 9.1
*/
public class RemovableCloseableIterator extends RemovableIterator implements CloseableIterator {
protected final CloseableIterator realIterator;
public RemovableCloseableIterator(CloseableIterator realIterator, Consumer super C> consumer) {
super(realIterator, consumer);
this.realIterator = realIterator;
}
@Override
public void close() {
currentValue = null;
previousValue = null;
realIterator.close();
}
}