com.jnape.palatable.lambda.functions.builtin.fn2.Map 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.functions.builtin.fn2;
import com.jnape.palatable.lambda.functions.Fn1;
import com.jnape.palatable.lambda.functions.Fn2;
import com.jnape.palatable.lambda.iterators.MappingIterator;
import java.util.function.Function;
/**
* Lazily apply a function to each element in an Iterable
, producing an Iterable
of the mapped
* results.
*
* @param A type contravariant to the input Iterable element type
* @param A type covariant to the output Iterable element type
*/
public final class Map implements Fn2, Iterable, Iterable> {
private Map() {
}
@Override
public Iterable apply(Function super A, ? extends B> fn, Iterable as) {
return () -> new MappingIterator<>(fn, as.iterator());
}
public static Map map() {
return new Map<>();
}
public static Fn1, Iterable> map(Function super A, ? extends B> fn) {
return Map.map().apply(fn);
}
public static Iterable map(Function super A, ? extends B> fn, Iterable as) {
return Map.map(fn).apply(as);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy