Conversation
cannot remember how this got here
Contributor
Reviewer's GuideRefactors stream-related APIs to live under java.util.stream, introduces IntStream and related functional interfaces, wires String/CharSequence methods to these stream types, and adjusts Arrays utilities and stubs to match the Java standard library surface more closely. Updated class diagram for java.util.stream and int functional typesclassDiagram
class AutoCloseable {
<<interface>>
+close() None
}
class BaseStream {
+close() None
+isParallel() bool
+iterator() Iterator
+onClose(closeHandler Runnable) Any
+parallel() Any
+sequential() Any
+spliterator() Spliterator
+unordered() Any
}
class Stream {
}
class Stream_Builder {
+accept(t Any) None
+add(t Any) Stream_Builder
+build() Stream
}
class IntStream {
+close() None
+isParallel() bool
+iterator() Iterator
+onClose(closeHandler Runnable) Any
+parallel() Any
+sequential() Any
+spliterator() Spliterator
+unordered() Any
}
class IntStream_Builder {
+accept(value int) None
+add(t int) IntStream_Builder
+build() IntStream
}
class IntStream_IntMapMultiConsumer {
+accept(value int, ic IntConsumer) None
+add(t Any) Stream_Builder
+build() Stream
}
class Consumer {
<<interface>>
+accept(t Any) None
}
class IntConsumer {
+accept(value int) None
+andThen(after IntConsumer) IntConsumer
}
class IntPredicate {
+negate() IntPredicate
+test(value int) bool
}
AutoCloseable <|-- BaseStream
BaseStream <|-- Stream
BaseStream <|-- IntStream
Consumer <|-- Stream_Builder
IntConsumer <|-- IntStream_Builder
Stream o-- Stream_Builder
IntStream o-- IntStream_Builder
IntStream o-- IntStream_IntMapMultiConsumer
IntStream_IntMapMultiConsumer ..> IntConsumer
Stream_Builder ..> Stream
IntStream_Builder ..> IntStream
Updated class diagram for java.lang String, CharSequence, Arrays and streamsclassDiagram
class CharSequence {
+charAt(index int) str
+chars() IntStream
+codePoints() IntStream
+length() int
}
class String {
+charAt(index int) unicode
+chars() IntStream
+codePointAt(index int) int
+codePointBefore(index int) int
+codePointCount(beginIndex int, endIndex int) int
+codePoints() IntStream
+length() int
+lines() Stream
}
class Arrays {
+asList(a Any) List~Any~
+stream(array Iterable~Any~, startInclusive int, endExclusive int) Stream
+toString(a List~Any~) str
}
class IntStream {
}
class Stream {
}
CharSequence <|-- String
CharSequence ..> IntStream : chars, codePoints
String ..> IntStream : chars, codePoints
String ..> Stream : lines
Arrays ..> Stream : stream
Arrays ..> Stream : stream return
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
IntStream.isParallelyou’re returningTrueunconditionally while the rest of the API is mostly placeholders; consider either raisingNotImplementedErroror matching the existingStreambehavior to avoid misleading semantics. - In
IntStream.IntMapMultiConsumer, theadd/buildmethods deal inStream.Builder/Streamrather thanIntStreamtypes; double-check that this is intentional and not a copy-paste mismatch with theIntStream-focused API.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `IntStream.isParallel` you’re returning `True` unconditionally while the rest of the API is mostly placeholders; consider either raising `NotImplementedError` or matching the existing `Stream` behavior to avoid misleading semantics.
- In `IntStream.IntMapMultiConsumer`, the `add`/`build` methods deal in `Stream.Builder`/`Stream` rather than `IntStream` types; double-check that this is intentional and not a copy-paste mismatch with the `IntStream`-focused API.
## Individual Comments
### Comment 1
<location> `src/java/util/stream/__init__.py:100-96` </location>
<code_context>
+ # type: () -> IntStream
+ raise NotImplementedError
+
+ class IntMapMultiConsumer(object):
+ def accept(self, value, ic):
+ # type: (int, IntConsumer) -> None
+ raise NotImplementedError
+
+ def add(self, t):
+ # type: (Any) -> Stream.Builder
+ pass
+
+ def build(self):
+ # type: () -> Stream
+ raise NotImplementedError
</code_context>
<issue_to_address>
**question:** IntMapMultiConsumer.add returning Stream.Builder looks inconsistent with the surrounding API and its purpose.
The `add` method’s `Stream.Builder` return type doesn’t align with an `IntStream`/`IntConsumer`-oriented helper. For a `mapMulti`-style consumer, you’d normally expose an `IntConsumer`-like API, not a builder. If this is meant to be a consumer, consider dropping the `add`/`build` methods and the builder return type; if it’s meant to be a builder, the naming and `accept` signature should be adjusted, and the return type might better be `IntStream.Builder` or another more appropriate type.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cannot remember how this got here
Summary by Sourcery
Introduce IntStream and functional int types while moving Stream from java.util to java.util.stream.
New Features:
Enhancements: