简体   繁体   English

原因:不存在类型变量 T 的实例,因此 void 符合 T

[英]reason: no instance(s) of type variable(s) T exist so that void conforms to T

I want to do nothing when cloudWatchRuleDestroy.destroy(@NonNull String ruleName) function of another class is called.当调用另一个类的 cloudWatchRuleDestroy.destroy(@NonNull String ruleName) 函数时,我什么也不想做。

I have tried Mock and InjectMocks but "cloudWatchRuleDestroyer.destroy(any())" makes the compiler show "reason: no instance(s) of type variable(s) T exist so that void conforms to T"我尝试过 Mock 和 InjectMocks 但“cloudWatchRuleDestroyer.destroy(any())”使编译器显示“原因:不存在类型变量 T 的实例,因此 void 符合 T”

    public void testHandleRequest() {
        doNothing().when(cloudWatchRuleDestroyer.destroy(any()));
        handler.handleRequest(inputMap);
    }

How to avoid this compiler error?如何避免这个编译器错误? What is the change I need to make?我需要做出什么改变?

Syntax of brackets is wrong.括号的语法是错误的。

Correct Syntax:正确的语法:

doReturn(someObject)
    .when(someInstance)
    .someMethod();

不兼容的类型:不存在类型变量 F、T 的实例,因此 java.util.Collection<t> 符合 java.util.Set <java.lang.long< div><div id="text_translate"><p> 我正在尝试将ComplexItem列表转换为它们对应的 ID Long列表。 但是即使在使用(Collection&lt;ComplexItem&gt;)对getCollection()调用进行类型转换后,也不会出现上述错误 go</p><pre> Set&lt;Long&gt; ids = Collections2.transform( getComplexItems(), new Function&lt;ComplexItem, Long&gt;() { @Override public Long apply(final ComplexItem item) { return item.id; } })); public List&lt;ComplexItem&gt; getComplexItems() {.............. }</pre> </div></java.lang.long<></t> - incompatible types: no instance(s) of type variable(s) F,T exist so that java.util.Collection<T> conforms to java.util.Set<java.lang.Long

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 原因:不存在类型变量 T 的实例,因此 void 符合使用 mockito - reason: no instance(s) of type variable(s) T exist so that void conforms to using mockito 不存在类型变量的实例,因此T符合注释 - No instance(s) of type variable(s) exist so that T conforms to Annotation 不兼容的类型:不存在类型变量 T 的实例,因此 Matcher<t> 符合 ArgumentMatcher<long></long></t> - incompatible types: no instance(s) of type variable(s) T exist so that Matcher<T> conforms to ArgumentMatcher<Long> 没有类型变量T的实例存在以便List <T> 符合Integer - No instance(s) of type variable(s) T exist so that List<T> conforms to Integer 不存在类型变量T的实例,因此ID符合Comparable <? super T> - No instance of type variable(s) T exist so that ID conforms to Comparable<? super T> 不存在类型变量 U 的实例,因此 void 符合 U - No instance(s) of type variable(s) U exist so that void conforms to U Java 错误:不兼容的类型:不存在类型变量 T 的实例,因此可选<t>符合 Iterable<availablelicence></availablelicence></t> - Java error: incompatible types: no instance(s) of type variable(s) T exist so that Optional<T> conforms to Iterable<AvailableLicence> 数组排序不起作用,不存在变量 T 的实例,因此 Employee 符合 Comparable - Array sort not working, no instance(s) of variable(s) T exist so that Employee conforms to Comparable 不兼容的类型:不存在类型变量 F、T 的实例,因此 java.util.Collection<t> 符合 java.util.Set <java.lang.long< div><div id="text_translate"><p> 我正在尝试将ComplexItem列表转换为它们对应的 ID Long列表。 但是即使在使用(Collection&lt;ComplexItem&gt;)对getCollection()调用进行类型转换后,也不会出现上述错误 go</p><pre> Set&lt;Long&gt; ids = Collections2.transform( getComplexItems(), new Function&lt;ComplexItem, Long&gt;() { @Override public Long apply(final ComplexItem item) { return item.id; } })); public List&lt;ComplexItem&gt; getComplexItems() {.............. }</pre> </div></java.lang.long<></t> - incompatible types: no instance(s) of type variable(s) F,T exist so that java.util.Collection<T> conforms to java.util.Set<java.lang.Long 不存在类型变量 V 的实例,因此 ExpectedCondition<Boolean> 符合功能<? super WebDriver, V> - No instance(s) of type variable(s) V exist so that ExpectedCondition<Boolean> conforms to Function<? super WebDriver, V>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM