I would like to simulate an optional .ifPresentThrow() to use somenthing like:
.ifPresent(MyException::go)
and not use:
.ifPresent(e -> {
throw new MyException();
})
so I created my class with the go method:
class MyException extends RuntimeException {
static void go() {
throw new MyException();
}
}
it's not work because the ifPresent hopes to receive a consumer x -> (), not a runnable () -> ()
adding some param to the function, I will have a unused param.
what's the best way to do this?