Package de.hsh.graja.util.cli
Class Option<T>
- java.lang.Object
-
- de.hsh.graja.util.cli.Option<T>
-
- Direct Known Subclasses:
BooleanOption
,DoubleOption
,IntegerOption
,KeyValuePairOption
,PathOption
,StringOption
public abstract class Option<T> extends Object
-
-
Constructor Summary
Constructors Constructor Description Option()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
convertImpl(OptionValue ov)
Converts a string-typed argument to the type represented by this DataType.DescribedOptionValue
getDefaultValue()
List<String>
getDescription()
Boolean
getMandatory()
List<String>
getMeaning()
String
getName()
List<ValidValues<T>>
getValidValues()
If any of the element in this list validates a given value as correct, then it is correct.boolean
isMandatory()
void
setDefaultValue(DescribedOptionValue defaultValue)
void
setDescription(List<String> description)
void
setMandatory(Boolean mandatory)
void
setMeaning(List<String> meaning)
void
setName(String name)
void
setValidValues(List<ValidValues<T>> validValues)
String
toString()
-
-
-
Method Detail
-
getName
public String getName()
-
setName
public void setName(String name)
-
getMandatory
public Boolean getMandatory()
- Returns:
- null means optional
-
isMandatory
public boolean isMandatory()
-
setMandatory
public void setMandatory(Boolean mandatory)
-
getDefaultValue
public DescribedOptionValue getDefaultValue()
-
setDefaultValue
public void setDefaultValue(DescribedOptionValue defaultValue)
-
getMeaning
public List<String> getMeaning()
- Returns:
- The meaning of a value of this data type. Most of the time the meaning is a word describing the data type itself. E. g. "number" or "path". Sometimes there are better names like "id", "file", "directory", "name", "format" etc. The meaning will be printed like this in the help page: <meaning>
-
getValidValues
public List<ValidValues<T>> getValidValues()
If any of the element in this list validates a given value as correct, then it is correct. Hence, the list is meant as union set of valid values.
-
setValidValues
public void setValidValues(List<ValidValues<T>> validValues)
-
convertImpl
protected abstract T convertImpl(OptionValue ov) throws InvalidValueException
Converts a string-typed argument to the type represented by this DataType. No validation against valid values will happen.- Parameters:
ov
-- Returns:
- converted value
- Throws:
InvalidValueException
-
-