@Target annotation commonly used parameter meaning:
-
ElementType.TYPE: Can be used for classes, interfaces, and enumeration types.
-
ElementType.FIELD: Can be used for fields.
-
ElementType.METHOD: Can be used for methods.
-
ElementType.PARAMETER: Can be used for method parameters.
-
ElementType.CONSTRUCTOR: Can be used for constructors.
-
ElementType.LOCAL_VARIABLE: Can be used for local variables.
-
ElementType.ANNOTATION_TYPE: Can be used for annotation types.
-
ElementType.PACKAGE: Can be used for packages.
-
ElementType.TYPE_PARAMETER: Can be used for type parameter declarations.
-
ElementType.TYPE_USE: Can be used in any statement that uses the type.
@Retention annotation commonly used parameter meanings:
-
RetentionPolicy.SOURCE: Annotations exist only in source code.
-
RetentionPolicy.CLASS: Annotations are only saved in the class.
-
RetentionPolicy.RUNTIME: The annotation not only exists in the source code but also has a class, which takes effect at runtime (most commonly used).