Skip to content

Commit ee41d80

Browse files
fix(skill): prefer direct primitive subtype streams
1 parent ed6571e commit ee41d80

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

skills/java-streams/SKILL.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ are equivalent.
4747
12+ min/max pair over the same input, and primitive stream terminal operations for primitive
4848
totals.
4949
3. Flatten nested sources deliberately. Use `flatMap` for nested collections and
50-
`flatMap(Optional::stream)` on Java 9+. On Java 16+, prefer `mapMulti` for mixed subtype checks or
51-
small conditional emission; use primitive streams for primitive results.
50+
`flatMap(Optional::stream)` on Java 9+. On Java 16+, prefer `mapMulti` for small conditional
51+
reference-value emission. For primitive values from a subtype, filter/cast first, then use
52+
`mapToInt`/`mapToLong`/`mapToDouble` directly; do not emit boxed primitives only to unbox them.
5253
4. Use primitive streams for primitive aggregation. Keep and explicitly classify `reduce(identity,
5354
op)` as acceptable for immutable non-primitive accumulation such as `BigDecimal`.
5455
5. Choose collectors by result semantics, and state duplicate-key/null contracts explicitly. When a

0 commit comments

Comments
 (0)