Adds missing comments for the converter argument class and adds a shorthand parameter
This commit is contained in:
parent
6cab649b1c
commit
87f2591d3b
@ -1,20 +1,60 @@
|
|||||||
package net.knarcraft.ffmpegconverter.parser;
|
package net.knarcraft.ffmpegconverter.parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing an argument
|
* A class representing a command argument
|
||||||
*/
|
*/
|
||||||
public class ConverterArgument {
|
public class ConverterArgument {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final char shorthand;
|
||||||
private final boolean valueRequired;
|
private final boolean valueRequired;
|
||||||
private final ConverterArgumentValue valueType;
|
private final ConverterArgumentValue valueType;
|
||||||
|
|
||||||
public ConverterArgument(String name, boolean valueRequired, ConverterArgumentValue valueType) {
|
/**
|
||||||
|
* Instantiates a converter argument
|
||||||
|
* @param name <p>The name of the argument which users has to type.</p>
|
||||||
|
* @param shorthand <p>A single character value for using the command.</p>
|
||||||
|
* @param valueRequired <p>Whether the argument must be followed by a valid value.</p>
|
||||||
|
* @param valueType <p>The type of value the argument requires.</p>
|
||||||
|
*/
|
||||||
|
public ConverterArgument(String name, char shorthand, boolean valueRequired, ConverterArgumentValue valueType) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.shorthand = shorthand;
|
||||||
this.valueRequired = valueRequired;
|
this.valueRequired = valueRequired;
|
||||||
this.valueType = valueType;
|
this.valueType = valueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean testArgumentValue(String value) {
|
/**
|
||||||
|
* Gets the argument name
|
||||||
|
* @return <p>The argument name.</p>
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the argument shorthand
|
||||||
|
* @return <p>The argument shorthand</p>
|
||||||
|
*/
|
||||||
|
public char getShorthand() {
|
||||||
|
return shorthand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the argument requires a value
|
||||||
|
* @return <p>Whether the argument requires a value.</p>
|
||||||
|
*/
|
||||||
|
public boolean isValueRequired() {
|
||||||
|
return valueRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether the given value is valid for this converter argument
|
||||||
|
*
|
||||||
|
* @param value <p>The value to test.</p>
|
||||||
|
* @return <p>True if the argument is valid. False otherwise.</p>
|
||||||
|
*/
|
||||||
|
public boolean testArgumentValue(String value) {
|
||||||
if (value.length() == 0) {
|
if (value.length() == 0) {
|
||||||
return !valueRequired;
|
return !valueRequired;
|
||||||
}
|
}
|
||||||
@ -26,9 +66,9 @@ public class ConverterArgument {
|
|||||||
String lower = value.toLowerCase();
|
String lower = value.toLowerCase();
|
||||||
return lower.equals("true") || lower.equals("false");
|
return lower.equals("true") || lower.equals("false");
|
||||||
case COMMA_SEPARATED_LIST:
|
case COMMA_SEPARATED_LIST:
|
||||||
return !value.contains(" ");
|
return true;
|
||||||
case SINGLE_VALUE:
|
case STRING:
|
||||||
return !value.contains(" ");
|
return true;
|
||||||
case INT:
|
case INT:
|
||||||
int ignored = Integer.parseInt(value);
|
int ignored = Integer.parseInt(value);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user