public static <T> Collector<T, ?, Optional<T>> maxBy (Comparator<? super T> comparator)

Returns a Collector that produces the maximal element according to a given Comparator, described as an Optional<T>.

Parameters:
<T>    the type of the input elements
comparator    a Comparator for comparing elements

Returns:  a Collector that produces the maximal value

@implSpec This produces a result equivalent to:


     reducing(BinaryOperator.maxBy(comparator))