Chciałbym łańcuchów BiFunctions, podobnie jak w metodzie chainWanted
w poniższym przykładzie kodu.Jak łańcuch BiFunctions?
BiFunction przyjmuje Funkcję jako parametr Andenna. czy można w jakiś sposób połączyć BiFunctions?
Kod tutaj nie kompiluje się z tego powodu i nie mogę rzucić BiFunction do funkcji.
import java.util.function.BiFunction;
import java.util.function.Function;
import org.openqa.selenium.remote.RemoteWebDriver;
public class Wf {
BiFunction<RemoteWebDriver, WfParams, RemoteWebDriver> init = this::init;
BiFunction<RemoteWebDriver, WfParams, RemoteWebDriver> wait = this::wait;
BiFunction<RemoteWebDriver, WfParams, RemoteWebDriver> chainNow = init
.andThen(d -> {
System.out.println("--------------");
return null;
});
BiFunction<RemoteWebDriver, WfParams, RemoteWebDriver> chainWanted = init
.andThen((BiFunction) wait);
public RemoteWebDriver init(RemoteWebDriver d, WfParams params) {
System.out.println("init(d, params)");
return d;
}
public RemoteWebDriver wait(RemoteWebDriver d, WfParams params) {
System.out.println("Wf.wait(d, params)");
return d;
}
public static void main(String[] args) throws Exception {
new Wf().start();
}
private void start() {
chainNow.apply(null, null);
}
}
Nie widzę sposobu na rozpoczęcie bifunkcji łańcuchowych; wynik bifunkcyjny jest pojedynczym argumentem, jak zamierzasz go połączyć w inny? – fge