public class EnumerationValidator extends Object implements AttributeValidator
Constructor and Description |
---|
EnumerationValidator(Set<String> values,
boolean ignoreCase)
Constructs an
EnumerationValidator with a given set of acceptable values. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
int |
hashCode() |
Optional<AttributeValidationReport> |
validate(Attribute attribute)
Validates a single
Attribute . |
public EnumerationValidator(Set<String> values, boolean ignoreCase)
EnumerationValidator
with a given set of acceptable values.ignoreCase
- whether enumeration validation should ignore case during evaluationvalues
- the values accepted by this validatorIllegalArgumentException
- if values
is null or emptypublic Optional<AttributeValidationReport> validate(Attribute attribute)
Attribute
.
Validates each of attribute
's values against the set of acceptable values by calling
String.valueOf(Object)
on each value and checking whether that string is in the set.
validate
in interface AttributeValidator
attribute
- the Attribute
to validate, cannot be nullOptional
containing an AttributeValidationReport
if there are
violations, or an empty Optional
if there are no violationsThis work is licensed under a Creative Commons Attribution 4.0 International License.