Use a switch-case instead of if-spaghettis

master
jvoisin 5 years ago
parent 6b54086590
commit e1a8a3b752
  1. 19
      airsonic-main/src/main/java/org/airsonic/player/util/StringUtil.java

@ -267,17 +267,16 @@ public final class StringUtil {
} }
String[] elements = s.split("_"); String[] elements = s.split("_");
switch (elements.length) {
if (elements.length == 0) { case 0:
return new Locale(s, "", ""); return new Locale(s, "", "");
} case 1:
if (elements.length == 1) { return new Locale(elements[0], "", "");
return new Locale(elements[0], "", ""); case 2:
} return new Locale(elements[0], elements[1], "");
if (elements.length == 2) { default:
return new Locale(elements[0], elements[1], ""); return new Locale(elements[0], elements[1], elements[2]);
} }
return new Locale(elements[0], elements[1], elements[2]);
} }
/** /**

Loading…
Cancel
Save