code: public static <T, I> TerminalOp<T, I>
      makeRef(Collector<? super T, I, ?> collector) {
          Supplier<I> supplier = Objects.requireNonNull(collector).supplier();
          BiConsumer<I, ? super T> accumulator = collector.accumulator();
          BinaryOperator<I> combiner = collector.combiner();
          class ReducingSink extends Box<I>
                  implements AccumulatingSink<T, I, ReducingSink> {
              @Override
              public void begin(long size) {
                  state = supplier.get();
              }
  
              @Override
              public void accept(T t) {
                  accumulator.accept(state, t);
              }
  
              @Override
              public void combine(ReducingSink other) {
                  state = combiner.apply(state, other.state);
              }
          }
          return new ReduceOp<T, I, ReducingSink>(StreamShape.REFERENCE) {
              @Override
              public ReducingSink makeSink() {
                  return new ReducingSink();
              }
  
              @Override
              public int getOpFlags() {
                  return collector.characteristics().contains(Collector.Characteristics.UNORDERED)
                         ? StreamOpFlag.NOT_ORDERED
                         : 0;
              }
          };
      }
docs: Constructs a {@code TerminalOp} that implements a mutable reduce on
  reference values.
  
  @param <T> the type of the input elements
  @param <I> the type of the intermediate reduction result
  @param collector a {@code Collector} defining the reduction
  @return a {@code ReduceOp} implementing the reduction