Moves argument related inner classes to own classes
This commit is contained in:
parent
a5e14b4ee5
commit
1090a61f2e
@ -0,0 +1,38 @@
|
||||
package net.knarcraft.ffmpegconverter.parser;
|
||||
|
||||
/**
|
||||
* A class representing an argument
|
||||
*/
|
||||
public class ConverterArgument {
|
||||
private final String name;
|
||||
private final boolean valueRequired;
|
||||
private final ConverterArgumentValue valueType;
|
||||
|
||||
public ConverterArgument(String name, boolean valueRequired, ConverterArgumentValue valueType) {
|
||||
this.name = name;
|
||||
this.valueRequired = valueRequired;
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
private boolean testArgumentValue(String value) {
|
||||
if (value.length() == 0) {
|
||||
return !valueRequired;
|
||||
}
|
||||
if (valueRequired && value.startsWith("-")) {
|
||||
return false;
|
||||
}
|
||||
switch (valueType) {
|
||||
case BOOLEAN:
|
||||
String lower = value.toLowerCase();
|
||||
return lower.equals("true") || lower.equals("false");
|
||||
case COMMA_SEPARATED_LIST:
|
||||
return !value.contains(" ");
|
||||
case SINGLE_VALUE:
|
||||
return !value.contains(" ");
|
||||
case INT:
|
||||
int ignored = Integer.parseInt(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package net.knarcraft.ffmpegconverter.parser;
|
||||
|
||||
public enum ConverterArgumentValue {
|
||||
BOOLEAN,
|
||||
COMMA_SEPARATED_LIST,
|
||||
SINGLE_VALUE,
|
||||
INT
|
||||
}
|
Loading…
Reference in New Issue
Block a user