Interface Constrained

All Known Implementing Classes:
ContentInfo, ContentRepository, DatabaseContentInfo, MetaData, RoleUser, Task, TaskOption, Validation

public interface Constrained
This interface defines methods for bean-centric constraining of data entities.

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 Details

    • addConstraint

      void addConstraint(ConstrainedBean constrainedBean)
      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 - the ConstrainedBean instance that has to be added
      Since:
      1.0
      See Also:
    • addConstraint

      void addConstraint(ConstrainedProperty constrainedProperty)
      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 - the ConstrainedProperty instance that has to be added
      Since:
      1.0
      See Also:
    • getConstrainedBean

      ConstrainedBean getConstrainedBean()
      Retrieves the constrained bean that has been set for this Constrained instance.
      Returns:
      the requested ConstrainedBean; or

      null if no ConstrainedBean 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 the ConstrainedProperty objects that are registered. If no constrained properties are available, an empty collection will be returned, not null.
      Since:
      1.0
      See Also:
    • hasPropertyConstraint

      boolean hasPropertyConstraint(String name)
      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; or

      false otherwise

      Since:
      1.0
      See Also:
    • getConstrainedProperty

      ConstrainedProperty getConstrainedProperty(String propertyName)
      Retrieve a registered ConstrainedProperty according to its name.
      Parameters:
      propertyName - the name of the ConstrainedProperty that has to be retrieved
      Returns:
      the requested ConstrainedProperty; or

      null if no such ConstrainedProperty is available.

      Since:
      1.0
      See Also: