AVal: Annotation Validation
AVal is an extendable meta-annotation based Annotation Validator for java 5. It provides a set of basic validation rules, as well as means to define more domain-specific ones.
AVal Latest (Beta) Release:
AVal 1.0b - Columbo -- release notes AVal 0.7 - Grissom -- release notes AVal 0.5b - Poncharello -- release notes -- readme AVal 0.1a - Clouseau -- release notes
Table of contents
Who is AVal for?
AVal is intended for framework programmers that use Java 5 annotations to express domain-specific concepts and need an expressive, declarative and self documenting way to encode the rules of use of their annotations.
What is AVal
AVal is an extendable meta-annotation based Annotation Validator for java 5. It provides a set of basic validation rules, as well as means to define more domain-specific ones.
AVal allows you to embed the way in which the annotations defined in your framework are to be validated. It can be seen as an extension of the @Target annotation provided in the Java5 JDK. An example of an AVal validated annotation would be:
@Inside(Web.class)
@AValTarget(CtMethod.class)
@Type(void.class)
public @interface Link {
@URLValue
String value();
}
How to use AVal
To use AVal it is enough to annotate your (base)annotations with some meta-annotations that define the way in which your annotations should be used.
Some of the build-in validations in AVal
Structural Validations
-
@Requires - States that a code element (for example a class) that is annotated by an Annotation, must also be annotated by another one.
-
@AValTarget - States on which code elements can an annotation be placed. This is a refinement from the Target Java5 annotation.
... more
Value Validations
-
@Matches - Restricts the values of an Annotation's attribute to only the ones that comply with a given regular expression.
-
@URLValue - States that the values of an Annotation's attribute must be valid URLs.
... more
A complete list of the available @Validators can be seen here and here.
Examples
(source for all these examples can be found in the Downloads? page)
- AVal.SimpleExample: A simple example
- AVal.ExampleFraclet:Validation of Fraclet annotations
- AVal.ExampleWebService: Validation of JSR181 annotations.
Architecture
AVal is completely based on annotations. There are 4 basic layers to AVal:
- Base program: The target program
- DSL Annotations: The annotations that implement domain-specific semantics.
- Validation Annotations: Meta-annotations that validate the DSL (see here for some examples)
- Implementation of Validation: The semantics of the Validation annotations
See the javadoc here

