code: public static <T, U> Collector<T, ?, Optional<T>> maxBy(Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
          class Accumulator {
              T t;
              U u;
          }
  
          return Collector.of(
              () -> new Accumulator(),
              (a, t) -> {
                  U u = function.apply(t);
  
                  if (a.u == null || comparator.compare(a.u, u) < 0) {
                      a.t = t;
                      a.u = u;
                  }
              },
              (a1, a2) ->
                    a1.u == null
                  ? a2
                  : a2.u == null
                  ? a1
                  : comparator.compare(a1.u, a2.u) < 0
                  ? a2
                  : a1,
              a -> Optional.ofNullable(a.t)
          );
      }
docs: Get a {@link Collector} that calculates the <code>MAX()</code> function.