Class 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 Detail

      • getConstrainedClass

        public static ConstrainedClass getConstrainedClass​(Class<?> theClass)
        Get the ConstrainedClass for 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 property
        IllegalArgumentException - if the propertyName is null
      • getConstrainedProperties

        public Set<String> getConstrainedProperties()
        Returns:
        a set of properties that have constraints associated with them