I need to change the following if
\'s to a switch
-case
while checking for a String
, to improve the cyclomatic complexity.<
Just to make concrete emory's answer, the executable code is the following :
Map> map = new HashMap>();
map.put( "test" , new Callable () { public User call (){ return fillUser("test" ); }} ) ;
map.put( "admin" , new Callable () { public Utente call (){ return fillUser("admin" ); }} ) ;
where user is a POJO, and then
User user = map.get(USERNAME).call();
finally the called method is somewhere :
private User fillUser(String x){
User user = new User();
// set something in User
return user;
}