Interface Constraint
-
- All Superinterfaces:
Serializable
public interface Constraint extends Serializable
A runtime instance of a constraint. This is a constraint definition that has been instantiated and had its parameters and other runtime references set. The construction of constraint objects has the following phases:- The object is constructed by calling
ConstraintFactory.create(). - The setParameterMappings() method will be called to set parameter values.
- The freeze() will be called.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidexecute(ConstraintContext context)Execute this constraint.voidfreeze()Freeze the values of constraint parameter mappings for this constraint instance.StringgetDisplayValue(ConstraintContext context, String parameterName, Object value)Calculate the display value for the given internal valueLOVCollectiongetLOV(ConstraintContext context, String parameterName, String query, int startAt, int fetchSize)Get an LOV for the specified parameter.LOVSupportgetLOVSupport(ConstraintContext context, String parameterName)Does this constraint provide LOV support for the specified parameter?voidsetParameterMappings(Iterator<? extends EntityDefinitionConstraintParameterMapping> parameterMappings)Set the parameter mappings for this constraint.booleansupportsArray()Returns true if this constraint is capable of handling array values, instead of a single value only.voidupdate(ConstraintContext context, String parameterName, String changedParameterName)Notifies constraint about parameter changesdefault voidvalidate()Validate the constraint parameter mappings provided to this constraint instance.
-
-
-
Method Detail
-
execute
void execute(ConstraintContext context) throws ConstraintViolatedException
Execute this constraint. This method MUST throw a ConstraintViolatedException if the constraint is not met, otherwise it MUST return.- Parameters:
context- the context in which the constraint is to execute.- Throws:
ConstraintViolatedException- if validation fails.RuntimeException- if there is an error in constraint execution.
-
getLOV
LOVCollection getLOV(ConstraintContext context, String parameterName, String query, int startAt, int fetchSize)
Get an LOV for the specified parameter.- Parameters:
context- the context in which the constraint is to execute.parameterName- the name of the parameter for which an LOV is required.query- a user specified query.startAt- the starting position for the query results.fetchSize- the fetch size for the query results.- Returns:
- an
LOVCollectionrepresenting the results.
-
getLOVSupport
LOVSupport getLOVSupport(ConstraintContext context, String parameterName)
Does this constraint provide LOV support for the specified parameter?- Parameters:
context- the context in which the constraint is to execute.parameterName- the name of the parameter for which an LOV is required.- Returns:
- an
LOVSupportobject representing the level of LOV support provided by this constraint for the specified parameter.
-
validate
default void validate()
Validate the constraint parameter mappings provided to this constraint instance.- Throws:
RuntimeException- if the constraint parameter mappings are invalid.
-
freeze
void freeze()
Freeze the values of constraint parameter mappings for this constraint instance.
-
setParameterMappings
void setParameterMappings(Iterator<? extends EntityDefinitionConstraintParameterMapping> parameterMappings)
Set the parameter mappings for this constraint.- Parameters:
parameterMappings- anIteratorofEntityDefinitionConstraintParameterMappingobjects representing the values of the parameters for this instance of the constraint definition.
-
getDisplayValue
String getDisplayValue(ConstraintContext context, String parameterName, Object value)
Calculate the display value for the given internal value- Parameters:
context-parameterName-value-- Returns:
- String
-
update
void update(ConstraintContext context, String parameterName, String changedParameterName)
Notifies constraint about parameter changes- Parameters:
context-parameterName-changedParameterName-
-
supportsArray
boolean supportsArray()
Returns true if this constraint is capable of handling array values, instead of a single value only.- Returns:
- True if it does, false otherwise.
-
-