com.jnape.palatable.lambda.iterators.MappingIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lambda Show documentation
Show all versions of lambda Show documentation
Functional patterns for Java
package com.jnape.palatable.lambda.iterators;
import java.util.Iterator;
import java.util.function.Function;
public class MappingIterator extends ImmutableIterator {
private final Function super A, ? extends B> function;
private final Iterator iterator;
public MappingIterator(Function super A, ? extends B> function, Iterator iterator) {
this.function = function;
this.iterator = iterator;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public B next() {
return function.apply(iterator.next());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy