Module bus.core

Interface UnaryOperatorX<T>

Type Parameters:
T - 参数和返回值类型
All Superinterfaces:
Function<T,T>, Serializable, UnaryOperator<T>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface UnaryOperatorX<T> extends UnaryOperator<T>, Serializable
可序列化的UnaryOperator接口,支持异常抛出和类型转换操作。
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default T
    apply(T t)
    对给定参数应用此操作,自动处理异常。
    对给定参数应用此操作,可能抛出异常。
    static <T, R, F extends Function<T, R>>
    UnaryOperatorX<T>
    casting(F function)
    返回一个支持类型转换的UnaryOperator。
    static <T> UnaryOperatorX<T>
    返回一个恒等UnaryOperator,始终返回输入参数。

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Method Details

    • identity

      static <T> UnaryOperatorX<T> identity()
      返回一个恒等UnaryOperator,始终返回输入参数。
      Type Parameters:
      T - 输入和输出的类型
      Returns:
      恒等UnaryOperator
    • casting

      static <T, R, F extends Function<T, R>> UnaryOperatorX<T> casting(F function)
      返回一个支持类型转换的UnaryOperator。
      Type Parameters:
      T - 输入参数类型
      R - 返回值类型
      F - 函数类型
      Parameters:
      function - 源函数
      Returns:
      类型转换后的UnaryOperator
    • applying

      T applying(T t) throws Throwable
      对给定参数应用此操作,可能抛出异常。
      Parameters:
      t - 输入参数
      Returns:
      操作结果
      Throws:
      Throwable - 可能抛出的异常
    • apply

      default T apply(T t)
      对给定参数应用此操作,自动处理异常。
      Specified by:
      apply in interface Function<T,T>
      Parameters:
      t - 输入参数
      Returns:
      操作结果
      Throws:
      RuntimeException - 包装后的运行时异常