假设我有以下代码:
public int getNumOfPostInstancesByTitle(String postMainTitle) {
int numOfIns = 0;
List<WebElement> blogTitlesList = driver.findElements(blogTitleLocator);
for (WebElement thisBlogTitle : blogTitlesList) {
String currentTitle = thisBlogTitle.getText();
if (currentTitle.equalsIgnoreCase(postMainTitle)) {
numOfIns++;
}
}
return numOfIns;
}
用谓词lambda转换它的正确方法是什么?