Custom stream extensions
Brian Goetz
brian.goetz at oracle.com
Sun Feb 3 14:18:07 PST 2013
Right. During initial development, all these classes were public,
mostly for convenience of testing.
There always has been an extensibility strategy in place, but it will
sadly not be ready for 8. Eventually, we will make public the XxxOp
classes, which will enable you to write your own ops, and thread them
into pipeline with the pipeline() method:
stream.filter(...)
.pipeline(myCustomOp(args))
.map(...)
...
The built-in ops all use this API, so we have been eating our own
dogfood. However, it is clear that this API is not yet ready to be
carved in stone. So the responsible thing to do is to keep it private
for now, until it is ready, at which point this extensibility mechanism
will be available to everyone.
On 2/3/2013 4:56 PM, Arul Dhesiaseelan wrote:
> I was able to add extensions to my custom list implementation in earlier
> builds.
>
> public MyStream<E> stream() {
> return new MyReferencePipeline<>(() -> Arrays.spliterator((E[])
> this.toArray(), 0, this.size()), StreamOpFlag.IS_SIZED |
> StreamOpFlag.IS_ORDERED);
> }
>
>
> Now that, ReferencePipeline is made package local, this approach is no
> longer possible.
>
> It was extremely useful to extend some of these core classes outside the
> package and toss in extensions with minimal coding. I assume this is not
> encouraged?
>
> Thanks,
> Arul
>
More information about the lambda-dev
mailing list