Interface Constrained
- All Known Implementing Classes:
MetaData,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 (
ConstrainedBeanconstraints) - those that only apply to a single property (
ConstrainedPropertyconstraints)
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddConstraint(ConstrainedBean constrainedBean) Add a new constrained bean.voidaddConstraint(ConstrainedProperty constrainedProperty) Add a new constrained property.Retrieves the constrained bean that has been set for thisConstrainedinstance.Returns a collection with all the constrained properties that have been registered.getConstrainedProperty(String propertyName) Retrieve a registeredConstrainedPropertyaccording to its name.booleanhasPropertyConstraint(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- theConstrainedBeaninstance 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- theConstrainedPropertyinstance that has to be added- Since:
- 1.0
- See Also:
-
getConstrainedBean
ConstrainedBean getConstrainedBean()Retrieves the constrained bean that has been set for thisConstrainedinstance.- Returns:
- the requested
ConstrainedBean; ornullif noConstrainedBeanis available. - Since:
- 1.0
- See Also:
-
getConstrainedProperties
Collection<ConstrainedProperty> getConstrainedProperties()Returns a collection with all the constrained properties that have been registered.- Returns:
- A
Collectionwith all theConstrainedPropertyobjects 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:
trueif this constraint is present on at least one of the properties; orfalseotherwise- Since:
- 1.0
- See Also:
-
getConstrainedProperty
Retrieve a registeredConstrainedPropertyaccording to its name.- Parameters:
propertyName- the name of theConstrainedPropertythat has to be retrieved- Returns:
- the requested
ConstrainedProperty; ornullif no suchConstrainedPropertyis available. - Since:
- 1.0
- See Also:
-