@Nonnull
    public static <T> AggregateOperation1<T, MutableReference<T>, T> maxBy(
            @Nonnull ComparatorEx<? super T> comparator
    ) {
        checkSerializable(comparator, "comparator");
        return AggregateOperation
                .withCreate(MutableReference<T>::new)
                .andAccumulate((MutableReference<T> a, T i) -> {
                    if (a.isNull() || comparator.compare(i, a.get()) > 0) {
                        a.set(i);
                    }
                })
                .andCombine((a1, a2) -> {
                    if (a1.isNull() || (!a2.isNull() && comparator.compare(a1.get(), a2.get()) < 0)) {
                        a1.set(a2.get());
                    }
                })
                .andExportFinish(MutableReference::get);
    }
@Test
    public void when_maxBy_noInput_then_nullResult() {
        // Given
        AggregateOperation1<String, MutableReference<String>, String> aggrOp = maxBy(naturalOrder());
        MutableReference<String> acc = aggrOp.createFn().get();

        // When
        String result = aggrOp.finishFn().apply(acc);

        // Then
        assertNull(result);
    }