Lisker
Sent: Monday, 28 April 2025 13:21
To: Viktor Klang
Cc: core-libs-dev@openjdk.org
Subject: [External] : Re: Casting gatherer
Hi Viktor,
stream.filter(myClass:isInstance).map(myClass:cast)
is indeed the current way of doing it. I've written this code many times and I
suspect others
Hi Viktor,
stream.filter(myClass:isInstance).map(myClass:cast)
is indeed the current way of doing it. I've written this code many times
and I suspect others have too. An extracted version might reside in many
utility classes. This is why I suggested having a Gatherer for it in
Gatherers. I've wri
The challenge here is that there is no, current, reification of a pattern
application, so all it boils down to at this point is: given a Predicate for
some type T, make a cast to some unrelated type R.
For Class-based retention of elements, it is possible to do the equivalent of
testing Class::
April 26, 2025 3:22 PM
To: Chen Liang
Cc: Nir Lisker ; core-libs-dev@openjdk.org
; amber-dev
Subject: [External] : Re: Casting gatherer
Didn't Brian or one of the Amber folks say that we might (some time in the near
future) get a .match() method on streams, which can take in a pattern
Didn't Brian or one of the Amber folks say that we might (some time in the
near future) get a .match() method on streams, which can take in a pattern?
It's the pattern version of .map().
On Sat, Apr 26, 2025 at 3:13 PM Chen Liang wrote:
> Hi Nir, I think currently the most similar code pattern i
Hi Nir, I think currently the most similar code pattern in stream that enjoys a
good performance is:
.mapMulti((x, sink) -> {
if (x instanceof MyClass myClass) {
sink.accept(myClass);
}
})
>From the language point of view, such pattern-match-and-map-0/1 operations may
>be common