checkers.igj.quals
Annotation Type I
@Documented
@Retention(value=RUNTIME)
@TypeQualifier
@SubtypeOf(value=ReadOnly.class)
public @interface I
Template annotation over IGJ Immutability annotations. It acts
somewhat similar to Type Variables in Generics. The annotation
value is used to distinguish between multiple instances of
@I
.
Usage On classes
A class annotated with I
could be declared with any IGJ
Immutability annotation. The actual immutability that @I
is
resolved dectates the immutability type for all the non-static
appearances of @I
with the same value as the class
declaration.
Example:
@I
public class FileDiscriptor {
private @Immutable Date creationData;
private @I Date lastModData;
public @I getLastModDate() @ReadOnly { }
}
...
void useFileDiscriptor() {
@Mutable FileDiscriptor file =
new @Mutable FileDiscriptor(...);
...
@Mutable Data date = file.getLastModDate();
}
In the last example, @I
was resolved to @Mutable
for
the instance file.
Usage On Methods
For example, it could be used for method parameters, return values,
and the actual IGJ immutability value would be resolved based on
the method invocation.
Example:
static @I Point getMidPoint(@I Point p1, @I Point p2)
{ ...}
The method would return a Point
object that returns a Point with
the same immutability type as the passed parameters if p1 and p2 match in
immutability, otherwise @I
is resolved to @ReadOnly
.
- checker.framework.manual
- #igj-checker IGJ Checker
value
public abstract String value
- Default:
- "I"