This document is the API specification for the Annotation based constraints framework.

This framework provides the capability to use Annotations to add validity constraints to JavaBeans properties and the classes to gain access to these constraints programatically. Additionally there are classes to perform validation of properties and JavaBean instances according to these constraints.

The following code snippet illustrates the core concept behind this framework. It shows two Annotations added to a property to constrain the legal values for that property. The example shows part of an Address class with a single property called street. On the setter method are two constraint annotations, ({@link com.sun.aus.constraints.annotation.MinLength MinLength} and {@link com.sun.aus.constraints.annotation.MaxLength MaxLength}), which together have the effect of constraining the length of the street property to between 10 and 20 characters, in order for the street to be valid.


 public class Address {
   private String street;

   public String getStreet() {
     return street;
   }

   {@literal @MinLength(10)}
   {@literal @MaxLength(20)}
   public void setStreet(String street) {
     this.street = street;
  }
}

Further examples are supplied in a sample file

The constraints themselves and classes involved in dealing directly with the constraints are defined in the annotation package.

An additional package validation is provided for validation. This is not an essential part of the framework. Validation may be done independently of this package. For example it could be handled by another frameworks such as JSF, JAXB etc.

Related Documentation

For overviews, tutorials, examples, guides, and tool documentation, please see: