A ConstrainedBean object makes it possible to define all
constraints for a bean instance that are not related to a single property.
The constraints here are global for the entire bean and either involve
several properties or are even totally unrelated to properties.
It's possible to add constraints to a ConstrainedProperty instance
through regular setters, but chainable setters are also available to make
it possible to easily define a series of constraints, for example:
ConstrainedBean constrained = new ConstrainedBean()
.unique("firstName", "lastName")
.defaultOrder("city")
.defaultOrder("lastName")
.defaultOrder("firstName");
A constrained bean is typically added to a
Constrained bean in
its constructor. These are the static constraints that will be set for each
and every instance of the bean. You'll however most of the time use the
Validation abstract class that provides the
Validation.activateValidation activateValidation method which initializes
the constraints on a need-to-have basis. This dramatically reduces memory
usage since otherwise all constraints will be initialized for every bean
instance, even though you don't use them.
author: Geert Bevin (gbevin[remove] at uwyn dot com) See Also: Constrained See Also: ConstrainedProperty version: $Revision: 3669 $ since: 1.0 |