Class ConstrainedClass
- java.lang.Object
-
- net.sourceforge.jbizmo.commons.validation.util.ConstrainedClass
-
public class ConstrainedClass extends Object
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConstrainedClassgetConstrainedClass(Class<?> theClass)Get theConstrainedClassfor the given classSet<String>getConstrainedProperties()Set<Annotation>getConstraints(String propertyName)Get an immutable set of constraints for a given property.static booleanisConstraint(Annotation annotation)
-
-
-
Method Detail
-
getConstrainedClass
public static ConstrainedClass getConstrainedClass(Class<?> theClass)
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
public static boolean isConstraint(Annotation annotation)
- Parameters:
annotation- the annotation to test- Returns:
- true if the given annotation is a Constraint
- Throws:
IllegalArgumentException- if the annotation is null
-
getConstraints
public Set<Annotation> getConstraints(String propertyName) throws IntrospectionException
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
-
-