I've never really liked the ?: ternary operator syntax, but the last time I taught CS1, I used a predominantly functional paradigm and it was natural to introduce ?: before if/else. Later on in the semester, when we had both features, we found that whenever we converted an if/else to a ?:, the code became significantly shorter and often clearer.
The ExtendedIntStream is just a class to add my custom pipeline operations to the IntStream class. I did this once before with the Stream class so I could add zip() and zipWith() operations.
ConditionallyMappingIntToObjectStream just stores a list of predicates, and an associated list of mapping functions. The elseMap() or elseFilter() method return a Stream which, when a terminal operator is invoked, will map each int using a different mapper, depending on which predicate tests as true for that element, or filters the element out if no predicates test true.
I didn't focus on code clarity, but on just proving it could work, so when I clean it up I'll repost the code.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop