Changes getListFromCommaSeparatedStringList to reduce its responsibility
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good

This commit is contained in:
2020-05-12 09:50:03 +02:00
parent f59152a819
commit b78aa7eb42
3 changed files with 14 additions and 17 deletions

View File

@ -111,11 +111,11 @@ class Main {
String[] subtitleLang = new String[]{"eng", "*"};
boolean toStereo = true;
boolean preventSigns = true;
if (input.size() > 0 && ListUtil.getListFromCommaSeparatedStringList(input, 0) != null) {
audioLang = ListUtil.getListFromCommaSeparatedStringList(input, 0);
if (input.size() > 0 && ListUtil.getListFromCommaSeparatedString(input.get(0)) != null) {
audioLang = ListUtil.getListFromCommaSeparatedString(input.get(0));
}
if (input.size() > 1 && ListUtil.getListFromCommaSeparatedStringList(input, 1) != null) {
subtitleLang = ListUtil.getListFromCommaSeparatedStringList(input, 1);
if (input.size() > 1 && ListUtil.getListFromCommaSeparatedString(input.get(1)) != null) {
subtitleLang = ListUtil.getListFromCommaSeparatedString(input.get(1));
}
if (input.size() > 2) {
toStereo = Boolean.parseBoolean(input.get(2));

View File

@ -65,18 +65,15 @@ public final class ListUtil {
/**
* Gets a list from a comma separated string at index in list
*
* @param list <p>A list of tokens.</p>
* @param index <p>The index of the token containing comma separated entries.</p>
* @param string <p>A string which may include commas.</p>
* @return <p>A string list.</p>
*/
public static String[] getListFromCommaSeparatedStringList(List<String> list, int index) {
String[] result = null;
if (list.size() > index) {
if (list.get(index).contains(",")) {
result = list.get(index).split(",");
} else {
result = new String[]{list.get(index)};
}
public static String[] getListFromCommaSeparatedString(String string) {
String[] result;
if (string.contains(",")) {
result = string.split(",");
} else {
result = new String[]{string};
}
return result;
}