@Override
    public <T, R, A> R apply(
        final SqlStreamOptimizerInfo<ENTITY> info,
        final SqlStreamTerminator<ENTITY> sqlStreamTerminator,
        final ReferencePipeline<T> pipeline,
        final Collector<? super T, A, R> collector
    ) {
        requireNonNull(info);
        requireNonNull(sqlStreamTerminator);
        requireNonNull(pipeline);
        requireNonNull(collector);

        final ReferencePipeline<T> optimizedPipeline = sqlStreamTerminator.optimize(pipeline);
        return sqlStreamTerminator
            .attachTraceData(optimizedPipeline)
            .getAsReferenceStream().collect(collector);
    }
@author Per Minborg
@param <ENTITY> the original stream entity source type
runtime-parent/runtime-core/src/main/java/com/speedment/runtime/core/internal/component/sql/override/def/reference/DefaultCollectTerminator.java