Class MaxWith<A>

  • Type Parameters:
    A - the value type
    All Implemented Interfaces:
    Fn1<java.util.Comparator<A>,​Fn1<A,​Fn1<A,​A>>>, Fn2<java.util.Comparator<A>,​A,​Fn1<A,​A>>, Fn3<java.util.Comparator<A>,​A,​A,​A>, SemigroupFactory<java.util.Comparator<A>,​A>, Applicative<Fn1<A,​Fn1<A,​A>>,​Fn1<java.util.Comparator<A>,​?>>, Cartesian<java.util.Comparator<A>,​Fn1<A,​Fn1<A,​A>>,​Fn1<?,​?>>, Cocartesian<java.util.Comparator<A>,​Fn1<A,​Fn1<A,​A>>,​Fn1<?,​?>>, Contravariant<java.util.Comparator<A>,​Profunctor<?,​Fn1<A,​Fn1<A,​A>>,​Fn1<?,​?>>>, Functor<Fn1<A,​Fn1<A,​A>>,​Fn1<java.util.Comparator<A>,​?>>, Profunctor<java.util.Comparator<A>,​Fn1<A,​Fn1<A,​A>>,​Fn1<?,​?>>, Monad<Fn1<A,​Fn1<A,​A>>,​Fn1<java.util.Comparator<A>,​?>>, MonadReader<java.util.Comparator<A>,​Fn1<A,​Fn1<A,​A>>,​Fn1<java.util.Comparator<A>,​?>>, MonadRec<Fn1<A,​Fn1<A,​A>>,​Fn1<java.util.Comparator<A>,​?>>, MonadWriter<java.util.Comparator<A>,​Fn1<A,​Fn1<A,​A>>,​Fn1<java.util.Comparator<A>,​?>>

    public final class MaxWith<A>
    extends java.lang.Object
    implements SemigroupFactory<java.util.Comparator<A>,​A>
    Given a comparator for some type A, produce a Semigroup over A that chooses between two values x and y via the following rules:
    • If x is strictly less than y in terms of B, return y
    • Otherwise, return x
    See Also:
    Max, MaxBy, MinWith
    • Field Detail

      • INSTANCE

        private static final MaxWith<?> INSTANCE
    • Constructor Detail

      • MaxWith

        private MaxWith()
    • Method Detail

      • maxWith

        public static <A> MaxWith<A> maxWith()
      • maxWith

        public static <A> Semigroup<A> maxWith​(java.util.Comparator<A> compareFn)
      • maxWith

        public static <A> Fn1<A,​A> maxWith​(java.util.Comparator<A> compareFn,
                                                 A x)
      • maxWith

        public static <A> A maxWith​(java.util.Comparator<A> compareFn,
                                    A x,
                                    A y)
      • checkedApply

        public Semigroup<A> checkedApply​(java.util.Comparator<A> comparator)
        Description copied from interface: Fn2
        Invoke this function with the given argument, potentially throwing any Throwable.
        Specified by:
        checkedApply in interface Fn1<java.util.Comparator<A>,​Fn1<A,​Fn1<A,​A>>>
        Specified by:
        checkedApply in interface Fn2<java.util.Comparator<A>,​A,​Fn1<A,​A>>
        Specified by:
        checkedApply in interface SemigroupFactory<java.util.Comparator<A>,​A>
        Parameters:
        comparator - the argument
        Returns:
        the result of the function application