Adds a new class for loading converter arguments
This commit is contained in:
parent
d6754b61cb
commit
1e3544f793
@ -0,0 +1,46 @@
|
||||
package net.knarcraft.ffmpegconverter.parser;
|
||||
|
||||
import net.knarcraft.ffmpegconverter.utility.FileUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class ConverterArgumentsLoader {
|
||||
|
||||
private List<ConverterArgument> converterArguments;
|
||||
|
||||
/**
|
||||
* Instantiates a new converter arguments loader and loads converter arguments
|
||||
*/
|
||||
ConverterArgumentsLoader() {
|
||||
this.converterArguments = new ArrayList<>();
|
||||
try {
|
||||
loadConverterArguments();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets loaded converter arguments
|
||||
* @return <p>The loaded converter arguments.</p>
|
||||
*/
|
||||
List<ConverterArgument> getConverterArguments() {
|
||||
return new ArrayList<>(this.converterArguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all converter arguments
|
||||
* @throws IOException <p>If unable to read the converter argument file.</p>
|
||||
*/
|
||||
private void loadConverterArguments() throws IOException {
|
||||
String[] arguments = FileUtil.readFileLines("converter_arguments.txt");
|
||||
for (String argument : arguments) {
|
||||
String[] argumentFields = argument.split("\\|");
|
||||
converterArguments.add(new ConverterArgument(argumentFields[0], argumentFields[1], Boolean.parseBoolean(argumentFields[2]),
|
||||
ConverterArgumentValue.valueOf(argumentFields[3])));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package net.knarcraft.ffmpegconverter.parser;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ConverterArgumentsLoaderTest {
|
||||
|
||||
@Test
|
||||
public void loadTest() {
|
||||
ConverterArgumentsLoader loader = new ConverterArgumentsLoader();
|
||||
assertEquals(14, loader.getConverterArguments().size());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user