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

fj.Bounded Maven / Gradle / Ivy

Go to download

Functional Java is an open source library that supports closures for the Java programming language

The newest version!
package fj;

/**
 * The Bounded class is used to name the upper and lower limits of a type.
 * Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.
 */
public final class Bounded {

    private final Definition def;

    /**
     * Minimal definition of Bounded
     */
    public interface Definition {
        A min();

        A max();
    }

    private Bounded(Definition definition) {
        this.def = definition;
    }

    public A min() {
        return def.min();
    }

    public A max() {
        return def.max();
    }

    public static  Bounded boundedDef(Definition def) {
        return new Bounded<>(def);
    }

    public static  Bounded bounded(A min, A max) {
        return boundedDef(new Definition() {
            @Override
            public A min() {
                return min;
            }

            @Override
            public A max() {
                return max;
            }
        });
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy