Alternative for throwingMerger in Java 8

Viewed 1733

I'm implementing own collector that uses merge function. Unfortunately, for some of my cases, I can't reuse the following JDK merger function that thrown IllegalStateException.

java.util.stream.Collectors#throwingMerger

It happens due to the fact that it has private access modifier and access from other(not inner) classes is restricted. However, javadoc says the following:

This can be used to enforce the assumption that the elements being collected are distinct

But, as I see, java doc is out of date. It can't be used. The question is whether JDK provides access to similar functionality for the java developers(similar method, constant etc) or one should write it on their own?

1 Answers
Related