streams: Java Stream API + Collectors cookbook module (creation, laziness and short-circuiting, intermediate/terminal ops, Collectors recipes and toMap traps, primitive stream overflow, parallel traps, Gatherers on JDK 25, loop-to-stream conversion), 12 contract tests

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b49nGy7tcEjVUa3WAA
This commit is contained in:
Claude
2026-11-24 05:52:24 +05:30
parent 9c2ae10d7f
commit 74da9cd899
28 changed files with 831 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
== 1. Nothing runs until a terminal operation ==
pipeline built, nothing printed above this line
now call toList():
peek saw 1
peek saw 2
peek saw 3
== 2. Elements flow one at a time through the whole pipeline ==
after filter: 1
after map : 1
after filter: 3
after map : 9
after filter: 5
after map : 25
== 3. Short-circuiting stops early ==
anyMatch(n > 10) = true, elements touched = 3 of 6
== 4. count() may skip the pipeline entirely ==
count = 3 (no peek lines: the size was known from the source)
peek saw 1
peek saw 2
peek saw 3
count after filter = 3 (filter makes the size unknown, so peek runs)
== 5. A stream is single use ==
IllegalStateException: stream has already been operated upon or closed