Use a switch-case instead of if-spaghettis

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

@ -267,18 +267,17 @@ 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:
if (elements.length == 2) {
return new Locale(elements[0], elements[1], ""); return new Locale(elements[0], elements[1], "");
} default:
return new Locale(elements[0], elements[1], elements[2]); return new Locale(elements[0], elements[1], elements[2]);
} }
}
/** /**
* URL-encodes the input value using UTF-8. * URL-encodes the input value using UTF-8.

Loading…
Cancel
Save