Class AbstractConstraint
- java.lang.Object
-
- org.alfresco.repo.dictionary.constraint.AbstractConstraint
-
- All Implemented Interfaces:
Constraint
- Direct Known Subclasses:
ListOfValuesConstraint,NoOpConstraint,NumericRangeConstraint,RegexConstraint,StringLengthConstraint
public abstract class AbstractConstraint extends Object implements Constraint
Base services for constraints.- Author:
- Derek Hulley
-
-
Field Summary
Fields Modifier and Type Field Description static StringERR_EVALUATE_EXCEPTIONstatic StringERR_PROP_NOT_SET
-
Constructor Summary
Constructors Constructor Description AbstractConstraint()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckPropertyNotNull(String name, Object value)Check that the given value is not null.voidevaluate(Object value)Evaluates a property value according to the implementation and initialization parameters provided.protected voidevaluateCollection(Collection<Object> collection)Only override if there is some specific evaluation that needs to be performed on the collection as a whole.protected abstract voidevaluateSingleValue(Object value)Support for evaluation of properties.Map<String,Object>getParameters()Returns the parameters passed to the instance of the constraint.StringgetShortName()Gets the constraint name.StringgetTitle()StringgetType()Returns the 'type' of the constraint, this is the identifier given to constraint in the configuration.voidinitialize()Initializes the constraint with appropriate values, which will depend on the implementation itself.voidset_shortName(String shortName)Deprecated.voidsetRegistry(ConstraintRegistry registry)Optionally specify the registry that will be used to register the constraint.voidsetShortName(String name)Sets the constraint namevoidsetTitle(String title)
-
-
-
Field Detail
-
ERR_PROP_NOT_SET
public static final String ERR_PROP_NOT_SET
- See Also:
- Constant Field Values
-
ERR_EVALUATE_EXCEPTION
public static final String ERR_EVALUATE_EXCEPTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
set_shortName
public void set_shortName(String shortName)
Deprecated.Sets the constraint name. Automatically called after construction. Please excuse the strange method name as we want the property name to begin with an underscore to avoid property name clashes.- Parameters:
shortName- String
-
setShortName
public void setShortName(String name)
Sets the constraint name- Parameters:
name- String
-
getShortName
public String getShortName()
Gets the constraint name.- Specified by:
getShortNamein interfaceConstraint- Returns:
- the constraint name.
-
setRegistry
public void setRegistry(ConstraintRegistry registry)
Optionally specify the registry that will be used to register the constraint. This is used when instantiating constraints outside the dictionary.- Parameters:
registry- the constraint registry
-
getType
public String getType()
Description copied from interface:ConstraintReturns the 'type' of the constraint, this is the identifier given to constraint in the configuration.- Specified by:
getTypein interfaceConstraint- Returns:
- The type
-
setTitle
public void setTitle(String title)
-
getTitle
public String getTitle()
- Specified by:
getTitlein interfaceConstraint- Returns:
- the human-readable constraint title (optional)
-
getParameters
public Map<String,Object> getParameters()
Description copied from interface:ConstraintReturns the parameters passed to the instance of the constraint.- Specified by:
getParametersin interfaceConstraint- Returns:
- Map of parameters or an empty Map if none exist
-
initialize
public 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.Registers the constraint with the registry, if present. Call this method if you want the constraint to be auto-registered.
- Specified by:
initializein interfaceConstraint
-
checkPropertyNotNull
protected void checkPropertyNotNull(String name, Object value)
Check that the given value is not null.- Parameters:
name- the name of the propertyvalue- the value to check for null- Throws:
DictionaryException- if the the property is null
-
evaluate
public final void evaluate(Object value)
Description copied from interface:ConstraintEvaluates a property value according to the implementation and initialization parameters provided.- Specified by:
evaluatein interfaceConstraint- Parameters:
value- the property value to check- See Also:
evaluateSingleValue(Object),evaluateCollection(Collection)
-
evaluateCollection
protected void evaluateCollection(Collection<Object> collection)
Only override if there is some specific evaluation that needs to be performed on the collection as a whole.- Parameters:
collection- the collection of values to evaluate- See Also:
evaluateSingleValue(Object)
-
evaluateSingleValue
protected abstract void evaluateSingleValue(Object value)
Support for evaluation of properties. The value passed in will never be a Collection and will never be null.- Throws:
ConstraintException- throw this when the evaluation fails
-
-