Provides the ability to set contraints against a properties of a class. Constraints can either be set via the property setters or via the
applyConstraint(String constraintName, Object constrainingValue)in combination with a constraint constant. Example:
...
ConstrainedProperty cp = new ConstrainedProperty(owningClass, propertyName, propertyType);
if (cp.supportsConstraint(ConstrainedProperty.EMAIL_CONSTRAINT)) {
cp.applyConstraint(ConstrainedProperty.EMAIL_CONSTRAINT, new Boolean(true));
}
Alternatively constraints can be applied directly using the java bean getters/setters if a static (as oposed to dynamic)
approach to constraint creation is possible:
cp.setEmail(true)
Constructor and description |
---|
ConstrainedProperty
(java.lang.Class<?> clazz, java.lang.String propertyName, java.lang.Class<?> propertyType) Constructs a new ConstrainedProperty for the given arguments. |
Type | Name and description |
---|---|
static void |
registerNewConstraint(java.lang.String name, ConstraintFactory factory) |
Constructs a new ConstrainedProperty for the given arguments.
clazz
- The owning classpropertyName
- The name of the propertypropertyType
- The property type