Have a function like this:
public void toDo(Req req)
if(req.getSection().equals("A")) {
return execA(req);
}
if(req.getSection().equals("B")) {
return execB(req);
}
if(req.getSection().equals("N")) {
return execN(req);
}
How can I simplify it? The general idea, how to exclude if statements for the identification type of function - Strings - A, B, N. Any solutions with Java 8 like pattern matching with Scala?
Thanks.
Aucun commentaire:
Enregistrer un commentaire