Changes getListFromCommaSeparatedStringList to reduce its responsibility
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
This commit is contained in:
parent
f59152a819
commit
b78aa7eb42
@ -111,11 +111,11 @@ class Main {
|
|||||||
String[] subtitleLang = new String[]{"eng", "*"};
|
String[] subtitleLang = new String[]{"eng", "*"};
|
||||||
boolean toStereo = true;
|
boolean toStereo = true;
|
||||||
boolean preventSigns = true;
|
boolean preventSigns = true;
|
||||||
if (input.size() > 0 && ListUtil.getListFromCommaSeparatedStringList(input, 0) != null) {
|
if (input.size() > 0 && ListUtil.getListFromCommaSeparatedString(input.get(0)) != null) {
|
||||||
audioLang = ListUtil.getListFromCommaSeparatedStringList(input, 0);
|
audioLang = ListUtil.getListFromCommaSeparatedString(input.get(0));
|
||||||
}
|
}
|
||||||
if (input.size() > 1 && ListUtil.getListFromCommaSeparatedStringList(input, 1) != null) {
|
if (input.size() > 1 && ListUtil.getListFromCommaSeparatedString(input.get(1)) != null) {
|
||||||
subtitleLang = ListUtil.getListFromCommaSeparatedStringList(input, 1);
|
subtitleLang = ListUtil.getListFromCommaSeparatedString(input.get(1));
|
||||||
}
|
}
|
||||||
if (input.size() > 2) {
|
if (input.size() > 2) {
|
||||||
toStereo = Boolean.parseBoolean(input.get(2));
|
toStereo = Boolean.parseBoolean(input.get(2));
|
||||||
|
@ -65,18 +65,15 @@ public final class ListUtil {
|
|||||||
/**
|
/**
|
||||||
* Gets a list from a comma separated string at index in list
|
* Gets a list from a comma separated string at index in list
|
||||||
*
|
*
|
||||||
* @param list <p>A list of tokens.</p>
|
* @param string <p>A string which may include commas.</p>
|
||||||
* @param index <p>The index of the token containing comma separated entries.</p>
|
|
||||||
* @return <p>A string list.</p>
|
* @return <p>A string list.</p>
|
||||||
*/
|
*/
|
||||||
public static String[] getListFromCommaSeparatedStringList(List<String> list, int index) {
|
public static String[] getListFromCommaSeparatedString(String string) {
|
||||||
String[] result = null;
|
String[] result;
|
||||||
if (list.size() > index) {
|
if (string.contains(",")) {
|
||||||
if (list.get(index).contains(",")) {
|
result = string.split(",");
|
||||||
result = list.get(index).split(",");
|
} else {
|
||||||
} else {
|
result = new String[]{string};
|
||||||
result = new String[]{list.get(index)};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,9 @@ public class ListUtilTest {
|
|||||||
inputList.add("some test string");
|
inputList.add("some test string");
|
||||||
inputList.add("some,test,string");
|
inputList.add("some,test,string");
|
||||||
inputList.add("some te,st string");
|
inputList.add("some te,st string");
|
||||||
String[] result1 = ListUtil.getListFromCommaSeparatedStringList(inputList, 0);
|
String[] result1 = ListUtil.getListFromCommaSeparatedString(inputList.get(0));
|
||||||
String[] result2 = ListUtil.getListFromCommaSeparatedStringList(inputList, 1);
|
String[] result2 = ListUtil.getListFromCommaSeparatedString(inputList.get(1));
|
||||||
String[] result3 = ListUtil.getListFromCommaSeparatedStringList(inputList, 2);
|
String[] result3 = ListUtil.getListFromCommaSeparatedString(inputList.get(2));
|
||||||
assertArrayEquals(new String[]{"some test string"}, result1);
|
assertArrayEquals(new String[]{"some test string"}, result1);
|
||||||
assertArrayEquals(new String[]{"some", "test", "string"}, result2);
|
assertArrayEquals(new String[]{"some", "test", "string"}, result2);
|
||||||
assertArrayEquals(new String[]{"some te", "st string"}, result3);
|
assertArrayEquals(new String[]{"some te", "st string"}, result3);
|
||||||
|
Loading…
Reference in New Issue
Block a user