Class OpenCollectors.CollectorFlow<E>

java.lang.Object
cloud.opencode.base.collections.OpenCollectors.CollectorFlow<E>
Type Parameters:
E - element type | 元素类型
Enclosing class:
OpenCollectors

public static final class OpenCollectors.CollectorFlow<E> extends Object
Fluent collection flow for chained operations. 用于链式操作的流式集合流。
Since:
JDK 25, opencode-base-collections V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • filter

      public OpenCollectors.CollectorFlow<E> filter(Predicate<? super E> predicate)
      Filter elements. 过滤元素。
      Parameters:
      predicate - the predicate | 谓词
      Returns:
      new flow | 新的流
    • map

      public <R> OpenCollectors.CollectorFlow<R> map(Function<? super E, ? extends R> mapper)
      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

      public OpenCollectors.CollectorFlow<E> distinct()
      Get distinct elements. 获取不同元素。
      Returns:
      new flow | 新的流
    • sorted

      public OpenCollectors.CollectorFlow<E> sorted()
      Sort elements. 排序元素。
      Returns:
      new flow | 新的流
    • sorted

      public OpenCollectors.CollectorFlow<E> sorted(Comparator<? super E> comparator)
      Sort elements with comparator. 使用比较器排序元素。
      Parameters:
      comparator - the comparator | 比较器
      Returns:
      new flow | 新的流
    • limit

      public OpenCollectors.CollectorFlow<E> limit(long maxSize)
      Limit elements. 限制元素数量。
      Parameters:
      maxSize - maximum size | 最大数量
      Returns:
      new flow | 新的流
    • skip

      public OpenCollectors.CollectorFlow<E> skip(long n)
      Skip elements. 跳过元素。
      Parameters:
      n - number to skip | 跳过数量
      Returns:
      new flow | 新的流
    • peek

      public OpenCollectors.CollectorFlow<E> peek(Consumer<? super E> action)
      Peek at elements. 窥视元素。
      Parameters:
      action - the action | 动作
      Returns:
      new flow | 新的流
    • toList

      public List<E> toList()
      Collect to List. 收集到 List。
      Returns:
      list | 列表
    • toArrayList

      public ArrayList<E> toArrayList()
      Collect to ArrayList. 收集到 ArrayList。
      Returns:
      ArrayList | ArrayList
    • toSet

      public Set<E> toSet()
      Collect to Set. 收集到 Set。
      Returns:
      set | 集合
    • toImmutableList

      public ImmutableList<E> toImmutableList()
      Collect to ImmutableList. 收集到 ImmutableList。
      Returns:
      immutable list | 不可变列表
    • toImmutableSet

      public ImmutableSet<E> toImmutableSet()
      Collect to ImmutableSet. 收集到 ImmutableSet。
      Returns:
      immutable set | 不可变集合
    • groupBy

      public <K> Map<K,List<E>> groupBy(Function<? super E, ? extends K> keyExtractor)
      Group by key. 按键分组。
      Type Parameters:
      K - key type | 键类型
      Parameters:
      keyExtractor - the key extractor | 键提取器
      Returns:
      grouped map | 分组 Map
    • partition

      public List<List<E>> partition(int size)
      Partition by size. 按大小分区。
      Parameters:
      size - partition size | 分区大小
      Returns:
      partitions | 分区列表
    • count

      public long count()
      Count elements. 计数元素。
      Returns:
      count | 数量
    • findFirst

      public Optional<E> findFirst()
      Find first element. 查找第一个元素。
      Returns:
      optional element | 可选元素
    • findAny

      public Optional<E> findAny()
      Find any element. 查找任意元素。
      Returns:
      optional element | 可选元素
    • anyMatch

      public boolean anyMatch(Predicate<? super E> predicate)
      Check if any match. 检查是否有任意匹配。
      Parameters:
      predicate - the predicate | 谓词
      Returns:
      true if any match | 如果有任意匹配则返回 true
    • allMatch

      public boolean allMatch(Predicate<? super E> predicate)
      Check if all match. 检查是否全部匹配。
      Parameters:
      predicate - the predicate | 谓词
      Returns:
      true if all match | 如果全部匹配则返回 true
    • noneMatch

      public boolean noneMatch(Predicate<? super E> predicate)
      Check if none match. 检查是否无匹配。
      Parameters:
      predicate - the predicate | 谓词
      Returns:
      true if none match | 如果无匹配则返回 true
    • forEach

      public void forEach(Consumer<? super E> action)
      For each element. 遍历每个元素。
      Parameters:
      action - the action | 动作
    • collect

      public <R,A> R collect(Collector<? super E, A, R> collector)
      Collect using a collector. 使用收集器收集。
      Type Parameters:
      R - result type | 结果类型
      A - accumulator type | 累加器类型
      Parameters:
      collector - the collector | 收集器
      Returns:
      result | 结果
    • stream

      public Stream<E> stream()
      Get the underlying stream. 获取底层流。
      Returns:
      stream | 流