public static <T> Collector<T, ?, Optional<T>> toOptional() {
        return toOptional(Optional::empty, Optional::of);
    }
Returns a {@code Collector} that accumulates 0 or 1 input elements into an {@code Optional<T>}.
The returned collector will throw {@code IllegalStateException} whenever 2 or more elements
are present in a stream. Null elements are mapped to {@code Optional.empty()}.

@param <T> the collected type
@return a {@code Collector} which collects 0 or 1 input elements into an {@code Optional<T>}.
core/src/main/java/org/jdbi/v3/core/collector/OptionalCollectors.java