org.sirix.index.IndexAxis Maven / Gradle / Ivy
package org.sirix.index;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Iterator;
import java.util.Set;
import org.sirix.index.avltree.AVLNode;
import org.sirix.index.avltree.keyvalue.NodeReferences;
import com.google.common.collect.AbstractIterator;
public final class IndexAxis>
extends AbstractIterator {
private final Iterator> mIter;
private final Set extends Filter> mFilter;
public IndexAxis(final Iterator> iter,
final Set extends Filter> filter) {
mIter = checkNotNull(iter);
mFilter = checkNotNull(filter);
}
@Override
protected NodeReferences computeNext() {
while (mIter.hasNext()) {
final AVLNode node = mIter.next();
boolean filterResult = true;
for (final Filter filter : mFilter) {
filterResult = filterResult && filter.filter(node);
if (!filterResult) {
break;
}
}
if (filterResult) {
return node.getValue();
} else {
return endOfData();
}
}
return endOfData();
}
}