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

jedi.functors.ConstantFunctor2 Maven / Gradle / Ivy

The newest version!
package jedi.functors;

import jedi.functional.Functor2;

/**
 * A {@link Functor2} that returns a constant regardless of its arguments.
 */
public class ConstantFunctor2 implements Functor2 {

    private final R r;

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

    /**
     * @see #constant(Object)
     */
    public static  ConstantFunctor2 constantFunctor2(R c) {
        return constant(c);
    }

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

    public R execute(Object a, Object b) {
        return r;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy