com.surelogic
Annotation Type MayReferTo


@Documented
@Target(value=TYPE)
public @interface MayReferTo

Constrains the set of types that a type is allowed to reference.

Semantics:

Places a structural constraint on the program's implementation. The annotated type is allowed to reference only types within the type set expression.

Examples:

Declaring that this type is allowed to reference a set of packages.
 @MayReferTo("com.surelogic.smallworld.model | org.jdom+ | java.{io, net, util}")
 class Example { ... }
 
The class Example is allowed to reference any type in the com.surelogic.smallworld.model package, any type in the org.jdom package and its subpackages, and any type any type in the UTIL typeset, and any type in the java.io, java.net, and java.util packages. Declaring that this type is allowed to reference most, but not all of a package.
 @MayReferTo("java.util & !(java.util.{Enumeration, Hashtable, Vector}")
 class Example2 { ... }
 
The class Example2 is allowed to reference all the types in the java.util package except for the Enumeration, Hashtable, and Vector classes.

Javadoc usage notes:

This annotation may placed in Javadoc, which can be useful for Java 1.4 code which does not include language support for annotations, via the @annotate tag.
 /**
  * @annotate MayReferTo("java.util")
  */
 class Example { ... }
 

See Also:
Layer, TypeSet

Required Element Summary
 String value
          The set of types that may be referred to.
 

Element Detail

value

public abstract String value
The set of types that may be referred to. This set is declared using a constructive syntax shared with several other annotations. The attribute is restricted to strings that match the following grammar:

value = type_set_expr

type_set_expr = type_set_disjunct *("|" type_set_disjunct) ; Set union

type_set_disjunct = type_set_conjunct *("&" type_set_conjunct) ; Set intersection

type_set_conjunct = ["!"] type_set_leaf ; Set complement

type_set_leaf = dotted_name ; Package name, layer name, type name, or type set name
type_set_leaf /= dotted_name "+" ; Package tree
type_set_leaf /= dotted_name "." "{" name *(", " name) "}" ; Union of packages/types
type_set_leaf /= "(" type_set_expr ")"

The union, intersection, and complement operators, as well as the parentheses have the obvious meanings, and standard precedence order. A package name signifies all the types in that package; a named type indicates a specific type. A named layer stands for all the types in the layer. A named type set stands for the type set specified by the given name, as defined by a @TypeSet annotation. The package tree suffix "+" indicates that all the types in the package and its subpackages are part of the set. The braces "{" "}" are syntactic sugar used to enumerate a union of packages/types that share the same prefix.



Copyright © 2011 Surelogic, Inc.. All Rights Reserved.