API question/request: Array to Stream

Millies, Sebastian Sebastian.Millies at softwareag.com
Wed Oct 2 01:18:06 PDT 2013


but Stream.of(T...) reads so much more elegant...

> -----Original Message-----
> From: lambda-dev-bounces at openjdk.java.net [mailto:lambda-dev-
> bounces at openjdk.java.net] On Behalf Of Gernot Neppert
> Sent: Wednesday, October 02, 2013 10:07 AM
> To: Brian Goetz
> Cc: lambda-dev
> Subject: Re: API question/request: Array to Stream
> 
> Oops, I hadn't noticed there were 2 factory methods at different places
> doing exactly the same thing.
> Won't this perpetually provoke the question "Which one should I use?"
> 
> Since java.util.Arrays has such a complete set of Stream-creation methods,
> maybe one could drop Stream.of(T...) in favour of Arrays.stream(T...)?
> 
> 
> 
> 2013/10/1 Brian Goetz <brian.goetz at oracle.com>
> 
> > Try
> >
> >   Arrays.stream(array)
> >
> > or
> >
> >   Stream.of(array)
> >
> >
> > On Oct 1, 2013, at 3:24 PM, Millies, Sebastian wrote:
> >
> > > Why can't I stream an array? It is awkward having to convert to a list
> > first, cf.
> > > this code by Venkat Subramaniam:
> > >
> > >  public void setFilters(Function<Color, Color>... filters) {
> > >        this.filter =
> > >                Arrays.asList(filters).stream()                  // <----
> > >                        .reduce((f, next) -> f.compose(next))
> > >                        .orElse(Function.<Color>identity());
> > >    }
> > >
> > > Sebastian Millies
> > > Software AG
> > > Expert webMethods Business Analytics
> > > Phone: +49 681 210-3221 | Fax: +49 681 210-1801
> > > Software AG
> > > Altenkesseler Str. 17 | 66115 Saarbrücken | Germany
> > > www.softwareag.com<http://www.softwareag.com>
> > >
> > >
> > > Software AG - Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt,
> > Germany - Registergericht/Commercial register: Darmstadt HRB 1562 -
> > Vorstand/Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman),
> > Dr. Wolfram Jost, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/Chairman of
> > the Supervisory Board: Dr. Andreas Bereczky - http://www.softwareag.com
> > >
> > >
> >
> >
> >



More information about the lambda-dev mailing list