Class EnumConstraint

java.lang.Object
org.nuxeo.ecm.core.schema.types.constraints.AbstractConstraint
org.nuxeo.ecm.core.schema.types.constraints.EnumConstraint
All Implemented Interfaces:
Serializable, Constraint

public class EnumConstraint extends AbstractConstraint

This constraint ensures some object's String representation is in an enumeration.

Since:
7.1
See Also:
  • Field Details

    • possibleValues

      protected final Set<String> possibleValues
  • Constructor Details

    • EnumConstraint

      public EnumConstraint(List<?> possibleValues)
      Supports any objects, use their String representation.
    • EnumConstraint

      public EnumConstraint(Object... possibleValues)
  • Method Details

    • validate

      public boolean validate(Object object)
      Description copied from interface: Constraint
      Validates the given object against this constraint.

      If some object is null. Constraint should return true while validating unless the constraint deals with nullable state.

      Parameters:
      object - the object to validate
      Returns:
      true if the object was successfully validated, false otherwise
    • getDescription

      public Constraint.Description getDescription()
      Here, value is :
      name = "EnumConstraint"
      parameter =
      • "Values" : List[value1, value2, value3]
      Returns:
      The constraint description.
    • getPossibleValues

      public Set<String> getPossibleValues()
    • getErrorMessage

      public String getErrorMessage(Object invalidValue, Locale locale)
      Description copied from interface: Constraint
      Provides an error message to display when some invalid value does not match existing entity.
      Specified by:
      getErrorMessage in interface Constraint
      Overrides:
      getErrorMessage in class AbstractConstraint
      Parameters:
      invalidValue - The invalid value that don't match any entity.
      locale - The language in which the message should be generated.
      Returns:
      A message in the specified language or
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object