Class ConstrainedClass
java.lang.Object
net.sourceforge.jbizmo.commons.validation.util.ConstrainedClass
A class to provide access to annotation-based property constraints. ConstrainedClass supports constraints that are added to the getters and setters of JavaBean properties. It does not support constraints added to either the field of the property or the method parameter of the setter.
Copyright 2010 (C) by Martin Ganserer
- Version:
- 1.0.0
- Author:
- Martin Ganserer
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConstrainedClassgetConstrainedClass(Class<?> theClass) Get theConstrainedClassfor the given classgetConstraints(String propertyName) Get an immutable set of constraints for a given property.static booleanisConstraint(Annotation annotation)
-
Method Details
-
getConstrainedClass
Get theConstrainedClassfor the given class- Parameters:
theClass- the class to be wrapped- Returns:
- the ConstrainedClass that wraps the given class
- Throws:
IllegalArgumentException- if the provided class is null
-
isConstraint
- Parameters:
annotation- the annotation to test- Returns:
- true if the given annotation is a Constraint
- Throws:
IllegalArgumentException- if the annotation is null
-
getConstraints
Get an immutable set of constraints for a given property. The constraints may be annotated either on the getter or the setter method and may be anywhere within the class hierarchy. The result is a set of constraints that must all be satisfied for the property to be valid.- Parameters:
propertyName- name of the property- Returns:
- the set (immutable) of constraints (annotations) or an empty set if there are no constraints on that property
- Throws:
IntrospectionException- if there are problems accessing the propertyIllegalArgumentException- if the propertyName is null
-
getConstrainedProperties
- Returns:
- a set of properties that have constraints associated with them
-