0
提供类以下结构:什么可迭代将与番石榴Iterables工作时,可以使用
public class Section extends IterableWidgetTemplate<Item>{
private List<WebElement> items1;
// other non iterable methods
private int indexOf(final Item item) {
int i = Iterables.indexOf(this, new Predicate<Item>() {
. . .
});
return i;
}
其中Iterables
是番石榴com.google.common.collect.Iterables
,根据其文档,包含了对对象进行操作的静态实用方法键入Iterable
。
现在在我上面描述的类中,this
作为iterable传递给private int indexOf()
方法。
问题:
- 我该怎么在
this
对象遍历?我是否正确假设Iterables
类将使用传递给它的对象中唯一可用的迭代方法?所以在这种情况下,我们有内部this
对象List<WebElement>
变量。 - 如果1.的答案是“是”,如果
Section
类有多个可迭代变量会发生什么?哪一个将用于迭代?