是否可以使用泛型传递接口的类型?
is it possible to pass the type of an interface with generics?
界面:
public interface AsyncCallback<T>
在我的测试方法中:
Mockito.any(AsyncCallback.class)
将 <ResponseX> 放在 .class 后面或为 .class 不起作用.
Putting <ResponseX> behind or for .class didnt work.
有一种类型安全的方法:使用 ArgumentMatchers.any() 并用类型限定它:
There is a type-safe way: use ArgumentMatchers.any() and qualify it with the type:
ArgumentMatchers.<AsyncCallback<ResponseX>>any()
这篇关于Mockito.any() 通过泛型接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何检测 32 位 int 上的整数溢出?How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
return 语句之前的局部变量,这有关系吗?Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
如何将整数转换为整数?How to convert Integer to int?(如何将整数转换为整数?)
如何在给定范围内创建一个随机打乱数字的 intHow do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
java的行为不一致==Inconsistent behavior on java#39;s ==(java的行为不一致==)
为什么 Java 能够将 0xff000000 存储为 int?Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)