Interface Constraint

All Known Implementing Classes:
AbstractConstraint, ListOfValuesConstraint, NoOpConstraint, NumericRangeConstraint, RegexConstraint, RegisteredConstraint, StringLengthConstraint

@AlfrescoPublicApi public interface Constraint
The interface for classes that implement constraints on property values.

Implementations of the actual constraint code should must not synchronize or in any other way block threads. Concurrent access of the evaluation method is expected, but will always occur after initialization has completed.

Attention to performance is crucial for all implementations as instances of this class are heavily used.

The constraint implementations can provide standard setter methods that will be populated by bean setter injection. Once all the available properties have been set, the contraint will be initialized.

Author:
Derek Hulley
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Evaluates a property value according to the implementation and initialization parameters provided.
    Returns the parameters passed to the instance of the constraint.
    Gets the constraint name.
     
    Returns the 'type' of the constraint, this is the identifier given to constraint in the configuration.
    void
    Initializes the constraint with appropriate values, which will depend on the implementation itself.
  • Method Details

    • getType

      String getType()
      Returns the 'type' of the constraint, this is the identifier given to constraint in the configuration.
      Returns:
      The type
    • getTitle

      String getTitle()
      Returns:
      the human-readable constraint title (optional)
    • getShortName

      String getShortName()
      Gets the constraint name.
      Returns:
      the constraint name.
    • getParameters

      Map<String,Object> getParameters()
      Returns the parameters passed to the instance of the constraint.
      Returns:
      Map of parameters or an empty Map if none exist
    • initialize

      void initialize()
      Initializes the constraint with appropriate values, which will depend on the implementation itself. This method can be implemented as a once-off, i.e. reinitialization does not have to be supported.
    • evaluate

      void evaluate(Object value)
      Evaluates a property value according to the implementation and initialization parameters provided.
      Parameters:
      value - the property value to check
      Throws:
      ConstraintException - if the value doesn't pass all constraints