Class FunctionalInterfaceUtil
java.lang.Object
cloud.opencode.base.reflect.lambda.FunctionalInterfaceUtil
Functional Interface Utility
函数式接口工具
Utilities for working with functional interfaces.
处理函数式接口的工具。
Features | 主要功能:
- Functional interface detection - 函数式接口检测
- Abstract method extraction - 抽象方法提取
- SAM (Single Abstract Method) analysis - SAM分析
Usage Examples | 使用示例:
boolean isFunctional = FunctionalInterfaceUtil.isFunctionalInterface(Runnable.class);
Method sam = FunctionalInterfaceUtil.getSingleAbstractMethod(Function.class);
Security | 安全性:
- Thread-safe: Yes (stateless utility class) - 线程安全: 是(无状态工具类)
- Null-safe: No (caller must ensure non-null arguments) - 空值安全: 否(调用方须确保非空参数)
Performance | 性能特性:
- Time complexity: O(m) where m is the number of methods in the interface - 时间复杂度: O(m),m为接口中的方法数量
- Space complexity: O(1) - 空间复杂度: O(1)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFunctional interface category 函数式接口类别 -
Method Summary
Modifier and TypeMethodDescriptionClassifies the functional interface type 分类函数式接口类型getAbstractMethods(Class<?> clazz) Gets all abstract methods of an interface 获取接口的所有抽象方法getDefaultMethods(Class<?> clazz) Gets default methods of an interface 获取接口的默认方法static intgetFunctionalMethodArity(Class<?> clazz) Gets the arity (parameter count) of the functional method 获取函数式方法的元数(参数数量)static Class<?>[]getFunctionalMethodParameterTypes(Class<?> clazz) Gets the parameter types of the functional method 获取函数式方法的参数类型static Class<?> getFunctionalMethodReturnType(Class<?> clazz) Gets the return type of the functional method 获取函数式方法的返回类型getSingleAbstractMethod(Class<?> clazz) Gets the single abstract method (SAM) of a functional interface 获取函数式接口的单一抽象方法(SAM)getStaticMethods(Class<?> clazz) Gets static methods of an interface 获取接口的静态方法static booleanhasNoParameters(Class<?> clazz) Checks if functional interface has no parameters 检查函数式接口是否没有参数static booleanisFunctionalInterface(Class<?> clazz) Checks if a class is a functional interface 检查类是否为函数式接口static booleanreturnsVoid(Class<?> clazz) Checks if functional interface returns void 检查函数式接口是否返回void
-
Method Details
-
isFunctionalInterface
Checks if a class is a functional interface 检查类是否为函数式接口- Parameters:
clazz- the class | 类- Returns:
- true if functional interface | 如果是函数式接口返回true
-
getSingleAbstractMethod
-
getAbstractMethods
-
getDefaultMethods
-
getStaticMethods
-
getFunctionalMethodReturnType
-
getFunctionalMethodParameterTypes
-
getFunctionalMethodArity
Gets the arity (parameter count) of the functional method 获取函数式方法的元数(参数数量)- Parameters:
clazz- the functional interface | 函数式接口- Returns:
- the arity | 元数
-
returnsVoid
Checks if functional interface returns void 检查函数式接口是否返回void- Parameters:
clazz- the functional interface | 函数式接口- Returns:
- true if returns void | 如果返回void返回true
-
hasNoParameters
Checks if functional interface has no parameters 检查函数式接口是否没有参数- Parameters:
clazz- the functional interface | 函数式接口- Returns:
- true if no parameters | 如果没有参数返回true
-
classify
Classifies the functional interface type 分类函数式接口类型- Parameters:
clazz- the functional interface | 函数式接口- Returns:
- the category | 类别
-