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

jedi.functors.ConstantFunctor Maven / Gradle / Ivy

The newest version!
package jedi.functors;

import jedi.functional.Functor;

/**
 * A {@link Functor} that returns a constant regardless of its argument.
 */
public class ConstantFunctor implements Functor {

    private final R r;

    /**
     * A convenient factory to create a constant functor.
     * @param c
     * @return a functor that will always return c
     */
    public static  ConstantFunctor constant(R c) {
        return new ConstantFunctor(c);
    }

    public ConstantFunctor(R r) {
        this.r = r;
    }

    public R execute(Object value) {
        return r;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy