我想注释vaadin的hascomponents类,它扩展了iterable。我可以这样注释迭代器()方法:
class com/vaadin/ui/HasComponents
iterator
()Ljava/util/Iterator<Lcom/vaadin/ui/Component;>;
()L1java/util/Iterator<L1com/vaadin/ui/Component;>;
这样我就可以用循环的经典迭代
for (Iterator<Component> it = content.iterator(); it.hasNext();) {
Component c = it.next();
doSmoething(c);
}
但当我尝试像
for(Component c : content) {
doSomething(c);
}
我收到了来自eclipse的警告:
Null type safety (type annotations): The expression of type 'Component' needs unchecked conversion to conform to '@NonNull Component'
大概是因为
HasComponents extends Component, Iterable<@NonNull Component>
是否有任何方法可以通过外部批注添加此批注,或者有其他方法?