Class OpenCollectors.CollectorFlow<E>
java.lang.Object
cloud.opencode.base.collections.OpenCollectors.CollectorFlow<E>
- Type Parameters:
E- element type | 元素类型
- Enclosing class:
OpenCollectors
Fluent collection flow for chained operations.
用于链式操作的流式集合流。
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if all match.booleanCheck if any match.<R,A> R Collect using a collector.longcount()Count elements.distinct()Get distinct elements.Filter elements.findAny()Find any element.Find first element.<R> OpenCollectors.CollectorFlow<R> FlatMap elements.voidFor each element.Group by key.limit(long maxSize) Limit elements.<R> OpenCollectors.CollectorFlow<R> Map elements.booleanCheck if none match.partition(int size) Partition by size.Peek at elements.skip(long n) Skip elements.sorted()Sort elements.sorted(Comparator<? super E> comparator) Sort elements with comparator.stream()Get the underlying stream.Collect to ArrayList.Collect to ImmutableList.Collect to ImmutableSet.toList()Collect to List.toSet()Collect to Set.
-
Method Details
-
filter
Filter elements. 过滤元素。- Parameters:
predicate- the predicate | 谓词- Returns:
- new flow | 新的流
-
map
Map elements. 映射元素。- Type Parameters:
R- result type | 结果类型- Parameters:
mapper- the mapper | 映射器- Returns:
- new flow | 新的流
-
flatMap
public <R> OpenCollectors.CollectorFlow<R> flatMap(Function<? super E, ? extends Stream<? extends R>> mapper) FlatMap elements. 扁平映射元素。- Type Parameters:
R- result type | 结果类型- Parameters:
mapper- the mapper | 映射器- Returns:
- new flow | 新的流
-
distinct
Get distinct elements. 获取不同元素。- Returns:
- new flow | 新的流
-
sorted
-
sorted
Sort elements with comparator. 使用比较器排序元素。- Parameters:
comparator- the comparator | 比较器- Returns:
- new flow | 新的流
-
limit
Limit elements. 限制元素数量。- Parameters:
maxSize- maximum size | 最大数量- Returns:
- new flow | 新的流
-
skip
Skip elements. 跳过元素。- Parameters:
n- number to skip | 跳过数量- Returns:
- new flow | 新的流
-
peek
Peek at elements. 窥视元素。- Parameters:
action- the action | 动作- Returns:
- new flow | 新的流
-
toList
-
toArrayList
-
toSet
-
toImmutableList
Collect to ImmutableList. 收集到 ImmutableList。- Returns:
- immutable list | 不可变列表
-
toImmutableSet
Collect to ImmutableSet. 收集到 ImmutableSet。- Returns:
- immutable set | 不可变集合
-
groupBy
-
partition
-
count
public long count()Count elements. 计数元素。- Returns:
- count | 数量
-
findFirst
-
findAny
-
anyMatch
-
allMatch
-
noneMatch
-
forEach
-
collect
-
stream
-