All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jnape.palatable.lambda.functions.builtin.fn1.Repeat Maven / Gradle / Ivy

There is a newer version: 5.5.0
Show newest version
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