/** * Adapts a {@code Collector} which accepts elements of type {@code Double} * to a {@code DoubleCollector}. * * @param <A> The intermediate accumulation type of the collector * @param <R> The final result type of the collector * @param collector a {@code Collector} to adapt * @return a {@code DoubleCollector} which behaves in the same way as input * collector. */ static <A, R> DoubleCollector<?, R> of(Collector<Double, A, R> collector) { if (collector instanceof DoubleCollector) { return (DoubleCollector<A, R>) collector; } return mappingToObj(Double::valueOf, collector); }