com.jnape.palatable.lambda.functions.builtin.fn1.Repeat 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 com.jnape.palatable.lambda.iterators.RepetitiousIterator;
/**
* Given a value, return an infinite Iterable
that repeatedly iterates that value.
*
* @param The Iterable element type
*/
public final class Repeat implements Fn1> {
private Repeat() {
}
@Override
public Iterable apply(A a) {
return () -> new RepetitiousIterator<>(a);
}
public static Repeat repeat() {
return new Repeat<>();
}
public static Iterable repeat(A a) {
return Repeat.repeat().apply(a);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy