@Documented @Retention(value=RUNTIME) @Target(value={TYPE,CONSTRUCTOR,METHOD,FIELD}) public @interface AllowsReferencesFrom
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 in the same package.
public class Aircraft {
@AllowsReferencesFrom("org.controls.Altimeter")
public double altitude;
...
}
The publicly-visible altitude field is constrained to only be
accessed from the org.controls.Altimeter class.
@annotate tag.
public class Place {
/**
* @annotate AllowsReferencesFrom("World")
*/
Place(World world, String name, String description) { ... }
...
}
MayReferTo,
TypeSetpublic abstract String value
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 © 2012 Surelogic, Inc.. All Rights Reserved.