Interface Constrained
- All Known Implementing Classes:
ContentInfo
,ContentRepository
,DatabaseContentInfo
,MetaData
,RoleUser
,Task
,TaskOption
,Validation
A constraint describes additional information about a data entity. Its main purpose is to alter the default behaviour of a data type and to clearly set the accepted limits. The meta-data that's provided through constraints can be used elsewhere to gather more information about how to correctly integrate the indicated data limits.
For example, a constraint specifies that a certain text's length is limited to 30 characters, parts of the system can query this information and act accordingly:
- a HTML form builder can create a field that doesn't allow the entry of longer text,
- a SQL query builder can limit the size of the column in which the text will stored when the table creation SQL is generated,
- a validation system can check if the text isn't longer than 30 characters and provide appropriate information when the length is exceeded.
There are two types of constraints:
- those that are related to the entire bean (
ConstrainedBean
constraints) - those that only apply to a single property (
ConstrainedProperty
constraints)
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addConstraint
(ConstrainedBean constrainedBean) Add a new constrained bean.void
addConstraint
(ConstrainedProperty constrainedProperty) Add a new constrained property.Retrieves the constrained bean that has been set for thisConstrained
instance.Returns a collection with all the constrained properties that have been registered.getConstrainedProperty
(String propertyName) Retrieve a registeredConstrainedProperty
according to its name.boolean
hasPropertyConstraint
(String name) Indicates whether this constrained bean contains a particular constraint on at least one of its properties.
-
Method Details
-
addConstraint
Add a new constrained bean.When several constrained beans are added, they are merged at constraint-level. This means for instance that all previous unique constraints will be replaced by those of the new constrained bean, they will not be combined.
- Parameters:
constrainedBean
- theConstrainedBean
instance that has to be added- Since:
- 1.0
- See Also:
-
addConstraint
Add a new constrained property.When several of the same constrained properties are added, they are merged at constraint-level. This means for instance that a previous inList constraint will be replaced by the one of the new constrained bean, they will not be combined.
- Parameters:
constrainedProperty
- theConstrainedProperty
instance that has to be added- Since:
- 1.0
- See Also:
-
getConstrainedBean
ConstrainedBean getConstrainedBean()Retrieves the constrained bean that has been set for thisConstrained
instance.- Returns:
- the requested
ConstrainedBean; or
null
if noConstrainedBean
is available. - Since:
- 1.0
- See Also:
-
getConstrainedProperties
Collection<ConstrainedProperty> getConstrainedProperties()Returns a collection with all the constrained properties that have been registered.- Returns:
- A
Collection
with all theConstrainedProperty
objects that are registered. If no constrained properties are available, an empty collection will be returned, notnull
. - Since:
- 1.0
- See Also:
-
hasPropertyConstraint
Indicates whether this constrained bean contains a particular constraint on at least one of its properties.- Returns:
true
if this constraint is present on at least one of the properties; orfalse
otherwise- Since:
- 1.0
- See Also:
-
getConstrainedProperty
Retrieve a registeredConstrainedProperty
according to its name.- Parameters:
propertyName
- the name of theConstrainedProperty
that has to be retrieved- Returns:
- the requested
ConstrainedProperty; or
null
if no suchConstrainedProperty
is available. - Since:
- 1.0
- See Also:
-