什么在匿名内部 class 中调用方法?

What calls a method inside an anonymous inner class?

在示例程序中 https://gist.github.com/bernii/5697073

在代码中

this.wait.until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver webDriver) {
                System.out.println("Searching ...");
                return webDriver.findElement(By.id("resultStats")) != null;
            }
});

什么调用了匿名内部的apply()方法class?

可能是 until 方法,它接收 ExpectedCondition<Boolean> 实例。这是唯一可以调用它的方法(除非 until 方法在某个实例变量(或静态变量)中存储对该实例的引用,而其他一些方法使用该引用来调用 apply 方法其他时间)。

Anonymous inner class 类似于本地 classes,只是它们没有名称。 ExpectedCondition 的 Subclass 将在后台创建,它将调用其中的方法。