com.jnape.palatable.lambda.functions.builtin.fn1.Magnetize 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.fn1;
import com.jnape.palatable.lambda.functions.Fn1;
import static com.jnape.palatable.lambda.functions.builtin.fn2.Eq.eq;
import static com.jnape.palatable.lambda.functions.builtin.fn2.MagnetizeBy.magnetizeBy;
/**
* {@link Magnetize} an {@link Iterable} using value equality as the magnetizing function.
*
* @param the Iterable element type
*/
public final class Magnetize implements Fn1, Iterable>> {
private static final Magnetize> INSTANCE = new Magnetize<>();
private Magnetize() {
}
@Override
public Iterable> checkedApply(Iterable as) {
return magnetizeBy(eq(), as);
}
@SuppressWarnings("unchecked")
public static Magnetize magnetize() {
return (Magnetize) INSTANCE;
}
public static Iterable> magnetize(Iterable as) {
return Magnetize.magnetize().apply(as);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy