com.happy3w.toolkits.iterator.StartActionIterator Maven / Gradle / Ivy
package com.happy3w.toolkits.iterator;
import java.util.Iterator;
import java.util.function.Consumer;
public class StartActionIterator implements IEasyIterator {
protected final Iterator innerIterator;
protected final Consumer startAction;
protected boolean performed = false;
public StartActionIterator(Iterator innerIterator, Consumer startAction) {
this.innerIterator = innerIterator;
this.startAction = startAction;
}
@Override
public boolean hasNext() {
return innerIterator.hasNext();
}
@Override
public T next() {
T nextValue = innerIterator.next();
if (!performed) {
startAction.accept(nextValue);
performed = true;
}
return nextValue;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy