Record Class Invocation
java.lang.Object
java.lang.Record
cloud.opencode.base.test.mock.Invocation
- Record Components:
method- the invoked method | 调用的方法args- the arguments | 参数timestamp- the invocation timestamp | 调用时间戳
Invocation - Record of a method invocation on a mock
调用记录 - Mock上方法调用的记录
Immutable record of a method invocation including method, arguments, and timestamp.
方法调用的不可变记录,包括方法、参数和时间戳。
Features | 主要功能:
- Immutable invocation recording - 不可变调用记录
- Argument matching support - 参数匹配支持
- Method name and type introspection - 方法名称和类型内省
Usage Examples | 使用示例:
Invocation inv = Invocation.of(method, args);
String name = inv.methodName();
boolean matches = inv.argsMatch("value1", 42);
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: Yes (handles null args) - 空值安全: 是(处理空参数)
- Since:
- JDK 25, opencode-base-test V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInvocation(Method method, Object[] args, Instant timestamp) Compact constructor — defensively copies args array. -
Method Summary
Modifier and TypeMethodDescriptionObject[]args()Returns a defensive copy of the arguments array.booleanChecks if arguments match.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanChecks if this invocation is for the specified method name.method()Returns the value of themethodrecord component.Gets the method name.static InvocationCreates an invocation with current timestamp.Class<?>[]Gets the parameter types.Class<?> Gets the return type.Returns the value of thetimestamprecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
Invocation
-
-
Method Details
-
args
Returns a defensive copy of the arguments array. 返回参数数组的防御性副本。- Returns:
- args copy or null | 参数副本或 null
-
of
Creates an invocation with current timestamp. 使用当前时间戳创建调用记录。- Parameters:
method- the method | 方法args- the arguments | 参数- Returns:
- the invocation | 调用记录
-
methodName
-
returnType
-
parameterTypes
Gets the parameter types. 获取参数类型。- Returns:
- the parameter types | 参数类型
-
argsMatch
Checks if arguments match. 检查参数是否匹配。- Parameters:
expectedArgs- the expected arguments | 期望参数- Returns:
- true if match | 如果匹配返回 true
-
isMethod
Checks if this invocation is for the specified method name. 检查此调用是否为指定方法名。- Parameters:
name- the method name | 方法名- Returns:
- true if match | 如果匹配返回 true
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
method
-
timestamp
-