Class PipeUtil.Pipe<T>

java.lang.Object
cloud.opencode.base.functional.pipeline.PipeUtil.Pipe<T>
Type Parameters:
T - value type - 值类型
Enclosing class:
PipeUtil

public static final class PipeUtil.Pipe<T> extends Object
Pipe - Value holder for pipe operations Pipe - 管道操作的值持有者
Since:
JDK 25, opencode-base-functional V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • then

      public <R> PipeUtil.Pipe<R> then(Function<? super T, ? extends R> function)
      Apply a transformation 应用转换
      Type Parameters:
      R - result type - 结果类型
      Parameters:
      function - transformation - 转换
      Returns:
      pipe with transformed value
    • thenIfPresent

      public <R> PipeUtil.Pipe<R> thenIfPresent(Function<? super T, ? extends R> function)
      Apply transformation if value is non-null 如果值非空则应用转换
      Type Parameters:
      R - result type - 结果类型
      Parameters:
      function - transformation - 转换
      Returns:
      pipe with transformed value or null
    • thenIf

      public PipeUtil.Pipe<T> thenIf(boolean condition, UnaryOperator<T> function)
      Apply transformation if condition is true 如果条件为真则应用转换
      Parameters:
      condition - condition to check - 要检查的条件
      function - transformation - 转换
      Returns:
      pipe with potentially transformed value
    • tap

      public PipeUtil.Pipe<T> tap(Consumer<? super T> consumer)
      Perform side effect without changing value 执行副作用而不改变值
      Parameters:
      consumer - side effect - 副作用
      Returns:
      this pipe
    • get

      public T get()
      Get the final value 获取最终值
      Returns:
      the value
    • getOrElse

      public T getOrElse(T defaultValue)
      Get the value or default if null 获取值或默认值(如果为 null)
      Parameters:
      defaultValue - default value - 默认值
      Returns:
      value or default