Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/java/lang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down
61 changes: 7 additions & 54 deletions src/java/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"Map",
"Properties",
"Spliterator",
"Stream",
"TimeZone",
"UUID",
]
Expand All @@ -54,7 +53,6 @@
Consumer,
Function,
Predicate,
Supplier,
ToDoubleFunction,
ToIntFunction,
ToLongFunction,
Expand All @@ -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):
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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):
Expand Down
22 changes: 22 additions & 0 deletions src/java/util/function/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"BinaryOperator",
"Consumer",
"Function",
"IntConsumer",
"IntPredicate",
"Predicate",
"Supplier",
"ToDoubleFunction",
Expand Down Expand Up @@ -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):
Expand Down
64 changes: 62 additions & 2 deletions src/java/util/stream/__init__.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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):
Expand Down
11 changes: 6 additions & 5 deletions stubs/stubs/java/lang/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand All @@ -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: ...
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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: ...
Expand Down
27 changes: 4 additions & 23 deletions stubs/stubs/java/util/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: ...
Expand Down
8 changes: 8 additions & 0 deletions stubs/stubs/java/util/function/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
Loading