Extending Collector to handle a post-transform
Brian Goetz
brian.goetz at oracle.com
Tue Jun 11 15:26:52 PDT 2013
> OK, scratch that. Here's a different approach:
> For example,
>
> /** Passed to Stream methods by client code */
> public interface Collector<T, R> {
> <X> Tuple<T, X, R> asTuple();
>
> /** Called on by Stream implementations to perform collection
> process */
> interface Tuple<T, X, R> {
> Supplier<X> resultSupplier();
> BiFunction<X, T, X> accumulator();
> BinaryOperator<X> combiner();
> Function<X, R> transformer();
> Set<Characteristics> characteristics();
> }
> }
Right, that's one of the forms of "move the ugly elsewhere."
But really, do you find this:
public static <T>
Collector<T, ?, List<T>> toList() { ... }
all that offensive? If you found that in the javadoc, would it really
make you wonder what that ? was all about? Because this is really as
bad as it gets.
More information about the lambda-libs-spec-observers
mailing list