Helper classes

Zhong Yu zhong.j.yu at
Mon Apr 15 10:13:57 PDT 2013

On Mon, Apr 15, 2013 at 3:53 AM, Stephen Colebourne
<scolebourne at> wrote:
> Currently, Project Lambda has a number of helper clases, notably
> Collectors and Streams, which are clearly related to the interface.
> Since JDK8 has static methods on interfaces, are there plans to move
> the static methods to the interface?
> This would allow methods such as  intBuilder(), emptyIntStream() and
> singletonIntStream(int t) to be on IntStream rather than on Stream,
> and thus have the simpler names of builder(), emptyStream(),
> singletonStream().
> Making the change might also affect some method names, as sometimes
> they read differently, or are otherwise confusing, when on the
> interface.
> As a note, on JSR-310, we did move the methods from similar static
> helper classes to the interfaces:
> although I'm not sure that counts as precedent yet.

Stephen, I feel it's ok to include one or two static factory methods
in an interface - it was very annoying to have to create another class
just to host one or two methods.

But in the two examples provided by you, there are a too many factory
methods, maybe they do belong to a separate class. Just from the
javadoc point of view, it doesn't feel right to say "this is an
interface of something; and by the way, a dozen of factory methods are
defined here too"

Zhong Yu

More information about the lambda-dev mailing list