Following work with one condition, variable name should be anything instead of "wait" , i.e. "wait1" would work
#CompleteWaitCode
@SuppressWarnings("unchecked")
Wait **wait1** = new FluentWait(driver).withTimeout(Duration.ofSeconds(30)).pollingEvery(Duration.ofSeconds(30)).ignoring(NoSuchElementException.class);
@SuppressWarnings("unchecked")
WebElement element = (WebElement) wait1.until(new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver arg0) {
WebElement linkelement = driver.findElement(By.cssSelector("button[class='btn btn-primary']"));
if (linkelement.isEnabled()) {
System.out.println("Element is Found");
}
return linkelement;
}
});