diff --git a/src/java/lang/__init__.py b/src/java/lang/__init__.py index a20e66f..f266163 100644 --- a/src/java/lang/__init__.py +++ b/src/java/lang/__init__.py @@ -44,6 +44,7 @@ from java.nio import CharBuffer from java.util import Iterator, Spliterator from java.util.function import Consumer + from java.util.stream import IntStream, Stream class Object(object): @@ -119,10 +120,12 @@ def charAt(self, index): # type: (int) -> str raise NotImplementedError - def chars(self): # type: ignore[no-untyped-def] + def chars(self): + # type: () -> IntStream pass - def codePoints(self): # type: ignore[no-untyped-def] + def codePoints(self): + # type: () -> IntStream pass @staticmethod @@ -291,7 +294,8 @@ def charAt(self, index): # type: (int) -> unicode pass - def chars(self): # type: ignore[no-untyped-def] + def chars(self): + # type: () -> IntStream pass def codePointAt(self, index): @@ -306,7 +310,8 @@ def codePointCount(self, beginIndex, endIndex): # type: (int, int) -> int pass - def codePoints(self): # type: ignore[no-untyped-def] + def codePoints(self): + # type: () -> IntStream pass @staticmethod @@ -392,7 +397,8 @@ def length(self): # type: () -> int return len(self) - def lines(self): # type: ignore[no-untyped-def] + def lines(self): + # type: () -> Stream pass def matches(self, regex): diff --git a/src/java/util/__init__.py b/src/java/util/__init__.py index e1a9d4d..b9ae3a0 100644 --- a/src/java/util/__init__.py +++ b/src/java/util/__init__.py @@ -31,7 +31,6 @@ "Map", "Properties", "Spliterator", - "Stream", "TimeZone", "UUID", ] @@ -54,7 +53,6 @@ Consumer, Function, Predicate, - Supplier, ToDoubleFunction, ToIntFunction, ToLongFunction, @@ -64,6 +62,7 @@ from java.io import InputStream, OutputStream from java.nio import ByteBuffer from java.time import Instant, ZonedDateTime, ZoneId + from java.util.stream import Stream class Collection(object): @@ -466,58 +465,7 @@ def trySplit(self): raise NotImplementedError -class Stream(object): - - class Builder(Consumer): - def accept(self, t): - # type: (Any) -> None - raise NotImplementedError - - def add(self, t): - # type: (Any) -> Stream.Builder - pass - - def build(self): - # type: () -> Stream - raise NotImplementedError - - @staticmethod - def builder(): - # type: () -> Builder - pass - - @staticmethod - def concat(a, b): - # type: (Stream, Stream) -> Stream - pass - - @staticmethod - def empty(): - # type: () -> Stream - pass - - @staticmethod - def generate(s): - # type: (Supplier) -> Stream - pass - - @staticmethod - def iterate(*args): - # type: (*Any) -> Stream - pass - - @staticmethod - def of(*args): - # type: (*Any) -> Stream - pass - - @staticmethod - def ofNullable(t): - # type: (Any) -> Stream - pass - - -class Arrays(Object): +class Arrays(object): @staticmethod def asList(a): # type: (Any) -> List[Any] @@ -607,6 +555,11 @@ def stream(array, startInclusive=None, endExclusive=None): # type: (Iterable[Any], Optional[int], Optional[int]) -> Stream pass + @staticmethod + def toString(a): + # type: (List[Any]) -> Union[str, unicode] + pass + class AbstractCollection(Object, Collection): def add(self, e): diff --git a/src/java/util/function/__init__.py b/src/java/util/function/__init__.py index c3db430..5f023c0 100644 --- a/src/java/util/function/__init__.py +++ b/src/java/util/function/__init__.py @@ -5,6 +5,8 @@ "BinaryOperator", "Consumer", "Function", + "IntConsumer", + "IntPredicate", "Predicate", "Supplier", "ToDoubleFunction", @@ -92,6 +94,26 @@ def identity(): pass +class IntConsumer(object): + def accept(self, value): + # type: (int) -> None + raise NotImplementedError + + def andThen(self, after): + # type: (IntConsumer) -> IntConsumer + pass + + +class IntPredicate(object): + def negate(self): + # type: () -> IntPredicate + pass + + def test(self, value): + # type: (int) -> bool + raise NotImplementedError + + class Predicate(object): @staticmethod def isEqual(targetRef): diff --git a/src/java/util/stream/__init__.py b/src/java/util/stream/__init__.py index 52713b2..f3cee02 100644 --- a/src/java/util/stream/__init__.py +++ b/src/java/util/stream/__init__.py @@ -1,10 +1,17 @@ -__all__ = ["BaseStream", "Collector", "Stream"] +__all__ = ["BaseStream", "Collector", "IntStream", "Stream"] from typing import Any, Iterable, Set from java.lang import AutoCloseable, Enum, Runnable from java.util import Iterator, Spliterator -from java.util.function import BiConsumer, BinaryOperator, Consumer, Function, Supplier +from java.util.function import ( + BiConsumer, + BinaryOperator, + Consumer, + Function, + IntConsumer, + Supplier, +) class BaseStream(AutoCloseable): @@ -75,6 +82,59 @@ def supplier(self): pass +class IntStream(BaseStream): + + class Builder(IntConsumer): + def accept(self, value): + # type: (int) -> None + raise NotImplementedError + + def add(self, t): + # type: (int) -> IntStream.Builder + pass + + def build(self): + # type: () -> IntStream + raise NotImplementedError + + class IntMapMultiConsumer(object): + def accept(self, value, ic): + # type: (int, IntConsumer) -> None + raise NotImplementedError + + def close(self): + # type: () -> None + pass + + def isParallel(self): + # type: () -> bool + return True + + def iterator(self): + # type: () -> Iterator + pass + + def onClose(self, closeHandler): + # type: (Runnable) -> Any + pass + + def parallel(self): + # type: () -> Any + pass + + def sequential(self): + # type: () -> Any + pass + + def spliterator(self): + # type: () -> Spliterator + pass + + def unordered(self): + # type: () -> Any + pass + + class Stream(BaseStream): class Builder(Consumer): diff --git a/stubs/stubs/java/lang/__init__.pyi b/stubs/stubs/java/lang/__init__.pyi index 675e239..2cbb6fa 100644 --- a/stubs/stubs/java/lang/__init__.pyi +++ b/stubs/stubs/java/lang/__init__.pyi @@ -5,6 +5,7 @@ from java.lang.reflect import Type from java.nio import CharBuffer from java.util import Iterator, Spliterator from java.util.function import Consumer +from java.util.stream import IntStream, Stream class Object: def __init__(self) -> None: ... @@ -30,8 +31,8 @@ class AutoCloseable: class CharSequence: def charAt(self, index: int) -> str: ... - def chars(self) -> None: ... - def codePoints(self) -> None: ... + def chars(self) -> IntStream: ... + def codePoints(self) -> IntStream: ... @staticmethod def compare(cs1: CharSequence, cs2: CharSequence) -> int: ... def length(self) -> int: ... @@ -88,11 +89,11 @@ class String(unicode): def __new__(cls, *args: Any) -> Any: ... def __init__(self, *args: Any) -> None: ... def charAt(self, index: int) -> unicode: ... - def chars(self) -> None: ... + def chars(self) -> IntStream: ... def codePointAt(self, index: int) -> int: ... def codePointBefore(self, index: int) -> int: ... def codePointCount(self, beginIndex: int, endIndex: int) -> int: ... - def codePoints(self) -> None: ... + def codePoints(self) -> IntStream: ... @staticmethod def compare(cs1: CharSequence, cs2: CharSequence) -> int: ... def compareTo(self, anotherString: String) -> int: ... @@ -121,7 +122,7 @@ class String(unicode): self, arg: Union[int, String], fromIndex: Optional[int] = ... ) -> int: ... def length(self) -> int: ... - def lines(self) -> None: ... + def lines(self) -> Stream: ... def matches(self, regex: String) -> bool: ... def notify(self) -> None: ... def notifyAll(self) -> None: ... diff --git a/stubs/stubs/java/util/__init__.pyi b/stubs/stubs/java/util/__init__.pyi index fbbc6cf..a1fa738 100644 --- a/stubs/stubs/java/util/__init__.pyi +++ b/stubs/stubs/java/util/__init__.pyi @@ -9,11 +9,11 @@ from java.util.function import ( Consumer, Function, Predicate, - Supplier, ToDoubleFunction, ToIntFunction, ToLongFunction, ) +from java.util.stream import Stream class Collection: def add(self, e: Any) -> bool: ... @@ -143,28 +143,7 @@ class Spliterator: def tryAdvance(self, action: Consumer) -> bool: ... def trySplit(self) -> Spliterator: ... -class Stream: - class Builder(Consumer): - def accept(self, t: Any) -> None: ... - def add(self, t: Any) -> Stream.Builder: ... - def build(self) -> Stream: ... - - @staticmethod - def builder() -> Builder: ... - @staticmethod - def concat(a: Stream, b: Stream) -> Stream: ... - @staticmethod - def empty() -> Stream: ... - @staticmethod - def generate(s: Supplier) -> Stream: ... - @staticmethod - def iterate(*args: Any) -> Stream: ... - @staticmethod - def of(*args: Any) -> Stream: ... - @staticmethod - def ofNullable(t: Any) -> Stream: ... - -class Arrays(Object): +class Arrays: @staticmethod def asList(a: Any) -> List[Any]: ... @staticmethod @@ -211,6 +190,8 @@ class Arrays(Object): startInclusive: Optional[int] = ..., endExclusive: Optional[int] = ..., ) -> Stream: ... + @staticmethod + def toString(a: List[Any]) -> Union[str, unicode]: ... class AbstractCollection(Object, Collection): def add(self, e: Any) -> bool: ... diff --git a/stubs/stubs/java/util/function/__init__.pyi b/stubs/stubs/java/util/function/__init__.pyi index 884efff..9411684 100644 --- a/stubs/stubs/java/util/function/__init__.pyi +++ b/stubs/stubs/java/util/function/__init__.pyi @@ -32,6 +32,14 @@ class Function: @staticmethod def identity() -> Function: ... +class IntConsumer: + def accept(self, value: int) -> None: ... + def andThen(self, after: IntConsumer) -> IntConsumer: ... + +class IntPredicate: + def negate(self) -> IntPredicate: ... + def test(self, value: int) -> bool: ... + class Predicate: @staticmethod def isEqual(targetRef: Object) -> Predicate: ... diff --git a/stubs/stubs/java/util/stream/__init__.pyi b/stubs/stubs/java/util/stream/__init__.pyi index e14a779..2db35e1 100644 --- a/stubs/stubs/java/util/stream/__init__.pyi +++ b/stubs/stubs/java/util/stream/__init__.pyi @@ -2,7 +2,14 @@ from typing import Any, Iterable, Set from java.lang import AutoCloseable, Enum, Runnable from java.util import Iterator, Spliterator -from java.util.function import BiConsumer, BinaryOperator, Consumer, Function, Supplier +from java.util.function import ( + BiConsumer, + BinaryOperator, + Consumer, + Function, + IntConsumer, + Supplier, +) class BaseStream(AutoCloseable): def close(self) -> None: ... @@ -27,6 +34,24 @@ class Collector: def of(*args: Any) -> Collector: ... def supplier(self) -> Supplier: ... +class IntStream(BaseStream): + class Builder(IntConsumer): + def accept(self, value: int) -> None: ... + def add(self, t: int) -> IntStream.Builder: ... + def build(self) -> IntStream: ... + + class IntMapMultiConsumer: + def accept(self, value: int, ic: IntConsumer) -> None: ... + + def close(self) -> None: ... + def isParallel(self) -> bool: ... + def iterator(self) -> Iterator: ... + def onClose(self, closeHandler: Runnable) -> Any: ... + def parallel(self) -> Any: ... + def sequential(self) -> Any: ... + def spliterator(self) -> Spliterator: ... + def unordered(self) -> Any: ... + class Stream(BaseStream): class Builder(Consumer): def accept(self, t: Any) -> None: ...