-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix(util): remove Stream class #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cannot remember how this got here
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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: