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 void
execute(ConstraintContext context)
Execute this constraint.void
freeze()
Freeze the values of constraint parameter mappings for this constraint instance.String
getDisplayValue(ConstraintContext context, String parameterName, Object value)
Calculate the display value for the given internal valueLOVCollection
getLOV(ConstraintContext context, String parameterName, String query, int startAt, int fetchSize)
Get an LOV for the specified parameter.LOVSupport
getLOVSupport(ConstraintContext context, String parameterName)
Does this constraint provide LOV support for the specified parameter?void
setParameterMappings(Iterator<? extends EntityDefinitionConstraintParameterMapping> parameterMappings)
Set the parameter mappings for this constraint.boolean
supportsArray()
Returns true if this constraint is capable of handling array values, instead of a single value only.void
update(ConstraintContext context, String parameterName, String changedParameterName)
Notifies constraint about parameter changesdefault void
validate()
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
LOVCollection
representing 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
LOVSupport
object 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
- anIterator
ofEntityDefinitionConstraintParameterMapping
objects 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.
-
-