Skip to content

Commit 3bac40c

Browse files
add javadocs for annotation
1 parent 9ef7d01 commit 3bac40c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/main/java/anthonisen/felix/annotationProcessing/MyVariance.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,54 @@
55
import java.lang.annotation.RetentionPolicy;
66
import java.lang.annotation.Target;
77

8+
/**
9+
* Indicates the variance characteristics of a type parameter.
10+
* <p>
11+
* This annotation can be used to specify whether a type parameter is
12+
* covariant, contravariant, or invariant, along with optional depth
13+
* and strictness settings.
14+
* </p>
15+
*
16+
* <h3>Usage Example:</h3>
17+
*
18+
* <pre>
19+
* {@code
20+
* public class ImmutableList<@MyVariance(variance = VarianceType.COVARIANT, depth = 100, strict = true) T> {
21+
* ...
22+
* }
23+
* </pre>
24+
*
25+
* @see VarianceType
26+
*/
827
@Retention(RetentionPolicy.SOURCE)
928
@Target(ElementType.TYPE_PARAMETER)
1029
public @interface MyVariance {
30+
/**
31+
* Specifies the variance type of the annotated type parameter.
32+
*
33+
* @return the variance type
34+
*/
1135
public VarianceType variance() default VarianceType.INVARIANT;
1236

37+
/**
38+
* Specifies the depth of variance. This can indicate how deep
39+
* the variance should apply within type hierarchies.
40+
*
41+
* @return the depth of variance
42+
*/
1343
public int depth() default Integer.MAX_VALUE;
1444

45+
/**
46+
* Indicates whether strict variance checking is enforced.
47+
*
48+
* <p>
49+
* If set to true, the compiler will enforce strict variance rules.
50+
* This means that compilation will fail if the specified variance
51+
* is not adhered to. If set to false, warnings are logged, but program will still compile.
52+
* </p>
53+
*
54+
* @return true if strict checking is enforced; false otherwise
55+
*/
1556
public boolean strict() default false;
1657

1758
}

0 commit comments

Comments
 (0)