public final class StreamMethods extends Object
Stream
-based operations,
so the Java Streams API
can be utilized in Gloop.Constructor and Description |
---|
StreamMethods() |
Modifier and Type | Method and Description |
---|---|
(package private) static Stream |
applyToTap(Stream stream,
UnaryOperator<Stream> streamAction,
Collection collection,
Function<Collection,Stream> collectionAction) |
(package private) static <T> T |
collectToSink(Stream stream,
Collection collection,
Function<Stream,T> function) |
static Long |
count(Stream stream)
Count the number of elements in the stream.
|
static Stream |
distinct(Stream stream,
Collection collection)
Filter out duplicate elements.
|
static Stream |
filter(Stream stream,
Collection collection,
groovy.lang.Closure<Boolean> predicate)
Filter items in the provided stream based on a given condition.
|
static void |
forEach(Stream stream,
groovy.lang.Closure consumer)
Consume each element of the stream to do a provided operation.
|
static io.toro.gloop.object.property.GloopModel |
groupBy(Stream<io.toro.gloop.object.property.GloopModel> stream,
Collection<io.toro.gloop.object.property.GloopModel> collection,
String groupBy)
Group together elements based on a Gloop model property.
|
static Stream |
limit(Stream stream,
Collection collection,
long limit)
Limit the items to process.
|
static Stream |
skip(Stream stream,
Collection collection,
long skip)
Skip the first n number of elements.
|
static Stream<io.toro.gloop.object.property.GloopModel> |
sorted(Stream<io.toro.gloop.object.property.GloopModel> stream,
Collection<io.toro.gloop.object.property.GloopModel> collection,
String sortBy)
Sort models by a certain property.
|
static Stream |
sorted(Stream stream,
Collection collection)
Sort items by their natural order.
|
static Stream |
sorted(Stream stream,
Collection collection,
groovy.lang.Closure<Integer> comparator)
Sort items based on a provided comparator.
|
static List |
toList(Stream stream)
Collect all elements in the stream, then return them as a
List . |
static Stream |
toStream(Collection collection)
Return a sequential
Stream with this collection as its source. |
@GloopObjectParameter(value="output:object::::::java.util.stream.Stream") public static Stream toStream(Collection collection)
Stream
with this collection as its source.collection
- collection data source collection data sourcestatic Stream applyToTap(Stream stream, UnaryOperator<Stream> streamAction, Collection collection, Function<Collection,Stream> collectionAction)
@GloopObjectParameter(value="output:object:::::java.util.stream.Stream") public static Stream filter(Stream stream, Collection collection, groovy.lang.Closure<Boolean> predicate)
stream
- stream data source stream data sourcecollection
- collection data source collection data sourcepredicate
- the condition for filteringIllegalArgumentException
- if both stream
and collection
are non-null and non-empty@GloopObjectParameter(value="output:object:::::java.util.stream.Stream") public static Stream sorted(Stream stream, Collection collection)
stream
- stream data source the stream data sourcecollection
- collection data source the collection data sourceIllegalArgumentException
- if both stream
and collection
are non-null and non-emptypublic static Stream sorted(Stream stream, Collection collection, groovy.lang.Closure<Integer> comparator)
stream
- stream data source stream data sourcecollection
- collection data source collection data sourcecomparator
- the closure to use to determine orderIllegalArgumentException
- if both stream
and collection
are non-null and non-empty@GloopObjectParameter(value="output:object:::::java.util.stream.Stream") public static Stream<io.toro.gloop.object.property.GloopModel> sorted(Stream<io.toro.gloop.object.property.GloopModel> stream, Collection<io.toro.gloop.object.property.GloopModel> collection, String sortBy)
stream
- stream data source stream data sourcecollection
- collection data source collection data sourcesortBy
- property to use as basis for sortingIllegalArgumentException
- if both stream
and collection
are non-null and non-empty@GloopObjectParameter(value="output:object:::::java.util.stream.Stream") public static Stream limit(Stream stream, Collection collection, long limit)
stream
- stream data sourcecollection
- collection data sourcelimit
- a limited stream of itemsIllegalArgumentException
- if both stream
and collection
are non-null and non-empty@GloopObjectParameter(value="output:object:::::java.util.stream.Stream") public static Stream skip(Stream stream, Collection collection, long skip)
stream
- stream data sourcecollection
- collection data sourceskip
- the number of leading elements to skipIllegalArgumentException
- if both stream
and collection
are non-null and non-empty@GloopObjectParameter(value="output:object:::::java.util.stream.Stream") public static Stream distinct(Stream stream, Collection collection)
stream
- stream data sourcecollection
- collection data sourceIllegalArgumentException
- if both stream
and collection
are non-null and non-empty@GloopObjectParameter(value="output:long") public static Long count(Stream stream)
stream
- stream data sourcestatic <T> T collectToSink(Stream stream, Collection collection, Function<Stream,T> function)
@GloopObjectParameter(value="output[]:object") public static List toList(Stream stream)
List
.stream
- stream data sourceList
of elements in the provided streampublic static void forEach(Stream stream, groovy.lang.Closure consumer)
stream
- stream data sourceconsumer
- the closure to apply to each item@GloopObjectParameter(value="output:a grouping of items from a stream{\ngroups[]{\nkey\nelements[]{\n}\n}\n}") public static io.toro.gloop.object.property.GloopModel groupBy(Stream<io.toro.gloop.object.property.GloopModel> stream, Collection<io.toro.gloop.object.property.GloopModel> collection, String groupBy)
stream
- stream data sourcecollection
- array data sourcegroupBy
- the property that will be used to group itemsIllegalArgumentException
- if both stream
and collection
are non-null and non-emptyCopyright © 2020. All rights reserved.