net.dpml.cli.validation

Class EnumValidator

public class EnumValidator extends Object implements 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));
 

Version: @PROJECT-VERSION@

Author: @PUBLISHER-NAME@

Constructor Summary
EnumValidator(Set values)
Creates a new EnumValidator for the specified values.
Method Summary
SetgetValidValues()
Returns the Set of valid argument values.
protected voidsetValidValues(Set validValues)
Specifies the Set of valid argument values.
voidvalidate(List values)
Validate the list of values against the list of permitted values.

Constructor Detail

EnumValidator

public EnumValidator(Set values)
Creates a new EnumValidator for the specified values.

Parameters: values The list of permitted values

Method Detail

getValidValues

public Set getValidValues()
Returns the Set of valid argument values.

Returns: Returns the Set of valid argument values.

setValidValues

protected void setValidValues(Set validValues)
Specifies the Set of valid argument values.

Parameters: validValues The Set of valid argument values.

validate

public void validate(List values)
Validate the list of values against the list of permitted values.

Parameters: values the list of values to validate

Throws: InvalidArgumentException if a value is invalid

See Also: validate