@SubtypeOf(value=ReadOnly.class) @Documented @Retention(value=RUNTIME) @Target(value={TYPE_USE,TYPE_PARAMETER}) public @interface I
@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 MethodsFor 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
.public abstract String value