Class Clamp<A extends java.lang.Comparable<A>>

  • Type Parameters:
    A - the bounds and input type
    All Implemented Interfaces:
    Fn1<A,​Fn1<A,​Fn1<A,​A>>>, Fn2<A,​A,​Fn1<A,​A>>, Fn3<A,​A,​A,​A>, Applicative<Fn1<A,​Fn1<A,​A>>,​Fn1<A,​?>>, Cartesian<A,​Fn1<A,​Fn1<A,​A>>,​Fn1<?,​?>>, Cocartesian<A,​Fn1<A,​Fn1<A,​A>>,​Fn1<?,​?>>, Contravariant<A,​Profunctor<?,​Fn1<A,​Fn1<A,​A>>,​Fn1<?,​?>>>, Functor<Fn1<A,​Fn1<A,​A>>,​Fn1<A,​?>>, Profunctor<A,​Fn1<A,​Fn1<A,​A>>,​Fn1<?,​?>>, Monad<Fn1<A,​Fn1<A,​A>>,​Fn1<A,​?>>, MonadReader<A,​Fn1<A,​Fn1<A,​A>>,​Fn1<A,​?>>, MonadRec<Fn1<A,​Fn1<A,​A>>,​Fn1<A,​?>>, MonadWriter<A,​Fn1<A,​Fn1<A,​A>>,​Fn1<A,​?>>

    public final class Clamp<A extends java.lang.Comparable<A>>
    extends java.lang.Object
    implements Fn3<A,​A,​A,​A>
    Given two bounds and a value, "clamp" the value between the bounds via the following algorithm: - if the value is strictly less than the lower bound, return the lower bound - if the value is strictly greater than the upper bound, return the upper bound - otherwise, return the value
    • Field Detail

      • INSTANCE

        private static final Clamp<?> INSTANCE
    • Constructor Detail

      • Clamp

        private Clamp()
    • Method Detail

      • checkedApply

        public A checkedApply​(A lower,
                              A upper,
                              A a)
        Specified by:
        checkedApply in interface Fn3<A extends java.lang.Comparable<A>,​A extends java.lang.Comparable<A>,​A extends java.lang.Comparable<A>,​A extends java.lang.Comparable<A>>
      • clamp

        public static <A extends java.lang.Comparable<A>> Clamp<A> clamp()
      • clamp

        public static <A extends java.lang.Comparable<A>> Fn2<A,​A,​A> clamp​(A lower)
      • clamp

        public static <A extends java.lang.Comparable<A>> Fn1<A,​A> clamp​(A lower,
                                                                               A upper)
      • clamp

        public static <A extends java.lang.Comparable<A>> A clamp​(A lower,
                                                                  A upper,
                                                                  A a)