public class EnumConstraint extends AbstractConstraint
This constraint ensures some object's String representation is in an enumeration.
Constraint.Description| Modifier and Type | Field and Description |
|---|---|
protected Set<String> |
possibleValues |
MESSAGES_BUNDLE, MESSAGES_DEFAULT_LANG, MESSAGES_KEY| Constructor and Description |
|---|
EnumConstraint(List<?> possibleValues)
Supports any objects, use their String representation.
|
EnumConstraint(Object... possibleValues) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
Constraint.Description |
getDescription()
Here, value is :
name = parameter = : List[value1, value2, value3] |
String |
getErrorMessage(Object invalidValue,
Locale locale)
Provides an error message to display when some invalid value does not match existing entity.
|
Set<String> |
getPossibleValues() |
int |
hashCode() |
boolean |
validate(Object object)
Validates the given object against this constraint.
|
getMessageString, toStringprotected final Set<String> possibleValues
public EnumConstraint(List<?> possibleValues)
public EnumConstraint(Object... possibleValues)
public boolean validate(Object object)
ConstraintIf some object is null. Constraint should return true while validating unless the constraint deals with nullable state.
object - the object to validatepublic Constraint.Description getDescription()
public Set<String> getPossibleValues()
public String getErrorMessage(Object invalidValue, Locale locale)
ConstraintgetErrorMessage in interface ConstraintgetErrorMessage in class AbstractConstraintinvalidValue - The invalid value that don't match any entity.locale - The language in which the message should be generated.Copyright © 2018 Nuxeo. All rights reserved.