public class EnumValidator extends Object implements Validator
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));
Constructor and Description |
---|
EnumValidator(Set values)
Creates a new EnumValidator for the specified values.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public EnumValidator(Set values)
values
- The list of permitted valuespublic void validate(List values) throws InvalidArgumentException
validate
in interface Validator
values
- The values to validate.InvalidArgumentException
- If any of the
specified values are not valid.Validator.validate(java.util.List)
public Set getValidValues()
protected void setValidValues(Set validValues)
validValues
- The Set of valid argument values.Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.