net.dpml.cli.validation
Class EnumValidator
java.lang.Object
net.dpml.cli.validation.EnumValidator
- Validator
The
EnumValidator
validates the string argument
values are valid.
The following example shows how to limit the valid values
for the color argument to 'red', 'green', or 'blue'.
Set values = new HashSet();
values.add("red");
values.add("green");
values.add("blue");
...
ArgumentBuilder builder = new ArgumentBuilder();
Argument color =
builder.withName("color");
.withValidator(new EnumValidator(values));
EnumValidator(Set values) - Creates a new EnumValidator for the specified values.
|
Set | getValidValues() - Returns the Set of valid argument values.
|
protected void | setValidValues(Set validValues) - Specifies the Set of valid argument values.
|
void | validate(List values) - Validate the list of values against the list of permitted values.
|
EnumValidator
public EnumValidator(Set values)
Creates a new EnumValidator for the specified values.
values
- The list of permitted values
getValidValues
public Set getValidValues()
Returns the Set of valid argument values.
- Returns the Set of valid argument values.
setValidValues
protected void setValidValues(Set validValues)
Specifies the Set of valid argument values.
validValues
- The Set of valid argument values.
validate
public void validate(List values)
throws InvalidArgumentException
Validate the list of values against the list of permitted values.
- validate in interface Validator
values
- the list of values to validate
net.dpml.cli.validation.Validator.validate(java.util.List)