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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
evaluate(java.lang.Object value)
Evaluates a property value according to the implementation and initialization parameters provided.java.util.Map<java.lang.String,java.lang.Object>
getParameters()
Returns the parameters passed to the instance of the constraint.java.lang.String
getShortName()
Gets the constraint name.java.lang.String
getTitle()
java.lang.String
getType()
Returns the 'type' of the constraint, this is the identifier given to constraint in the configuration.void
initialize()
Initializes the constraint with appropriate values, which will depend on the implementation itself.
-
-
-
Method Detail
-
getType
java.lang.String getType()
Returns the 'type' of the constraint, this is the identifier given to constraint in the configuration.- Returns:
- The type
-
getTitle
java.lang.String getTitle()
- Returns:
- the human-readable constraint title (optional)
-
getShortName
java.lang.String getShortName()
Gets the constraint name.- Returns:
- the constraint name.
-
getParameters
java.util.Map<java.lang.String,java.lang.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(java.lang.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
-
-