reduce the number of non-empty switch cases sonar lint issue

谁说胖子不能爱 提交于 2020-06-01 06:26:08

问题


I have around 100 non-empty cases inside a switch case. Each case calls different functions. Sonar is showing issue to reduce number of non-empty switch cases to atmost 30. Is there any alternative to implement such switch cases or there is no problem in having any number of switch cases.

    for(int i=0;i<arrayList.size();i++){
       switch(arrayList.get(i)){
          case "A":
             a();
            break;

          case "B":
             b(10,20);
            break;

             ...
             ...

          case "ABZ":
             abz("string1","string2");
           break;
       }
    }

来源:https://stackoverflow.com/questions/61243218/reduce-the-number-of-non-empty-switch-cases-sonar-lint-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!