public static <T, U> Collector<T, ?, Optional<T>> percentileBy(double percentile, Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
        if (percentile < 0.0 || percentile > 1.0)
            throw new IllegalArgumentException("Percentile must be between 0.0 and 1.0");

        if (percentile == 0.0)
            return minBy(function, comparator);
        else if (percentile == 1.0)
            return collectingAndThen(maxAllBy(function, comparator), Seq::findLast);
        else
            return percentileCollector(
                function,
                comparator,
                Optional::empty,
                Optional::of,
                l -> Optional.of(l.get(percentileIndex(percentile, l.size())).v1)
            );
    }
Get a {@link Collector} that calculates the derived <code>PERCENTILE_DISC(percentile)</code> function given a specific ordering.
jOOL-java-8/src/main/java/org/jooq/lambda/Agg.java