com.surelogic
Annotation Type AllowsReferencesFrom


@Documented
@Target(value={TYPE,CONSTRUCTOR,METHOD,FIELD})
public @interface AllowsReferencesFrom

Constrains the set of types that are allowed to reference the annotated program element. This annotation may target a type, a method, a constructor, or a field.

Examples:

Declaring that a constructor can only be called from within a particular type.
 package com.surelogic.smallworld.model;
 
 public class Place {
 
   @AllowsReferencesFrom("World")
   Place(World world, String name, String description) { ... }
   
   ...
 }
 
The constructor for the Place class shown above is allowed, by the Java language, to be invoked from any type within the com.surelogic.smallworld.model package. The AllowsReferencesFrom annotation restricts this visibility further to only the World class.

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.
 public class Place {
 
   /**
    * @annotate AllowsReferencesFrom("World")
    */
   Place(World world, String name, String description) { ... }
   
   ...
 }
 

See Also:
MayReferTo, TypeSet

Required Element Summary
 String value
          The set of types that may refer to the type.
 

Element Detail

value

public abstract String value
The set of types that may refer to the type. 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 © 2010 Surelogic, Inc.. All Rights Reserved.