syntax requirements for custom annotations
The keyword defining a custom annotation is @interface
Members are declared with no exception, can assign a default value to the member (default), the type of the member is restricted, the legal type has the basic data type and string,class,annotation,enumeration; If the annotation has only one member, it must be named value (), and the member name and "=" can be ignored when used
Note Classes can have no members, which is called identity annotations
__________________________________________________________________________
Meta annotations
Java5.0 defines 4 standard meta-annotation types, which are used to provide descriptions of other annotation types.
The defined meta annotations are (java.lang.annotation):
@Target
@Retertion
@Inherited
@Documented
1) @Target: The scope of the annotation's modified random thoughts, that is, the scope of the modified annotations
The value of the ElementType is
1.CONSTRUCTOR: Used to describe the constructor
2.FIELD: Used to describe the domain
3.local_variable: Used to describe local variables
4.METHOD: Used to describe the method
5.PACKAGE: Used to describe the package
6.PARAMETER: Used to describe parameters
7.TYPE: Used to describe classes, interfaces (including annotation types) or enum declarations
PS: Separated by "," between each parameter
2) @Retertion: Defines the length of time that the annotation is retained, that is, the extent to which the described annotation is valid
Retentionpoicy) are:
1.SOURCE: Valid in source file (i.e., source file retention)
2.CLASS: Valid in class file (that is, class reserved)
3.RUNTIME: Valid at run time (that is, runtime retention)
3) @Inherited: Allow subclasses to be inherited
4) @Documented: Describe other types of annotation that should be used as public APIs for annotated program members, so they can be documented by tools such as Javadoc. Documented is a markup annotation with no members.
__________________________________________________________________________
Working with custom annotations
Syntax:@< annotation name > (< member name 1>=< member value 1>,< member name 2>=< member value 3>,...)
Custom annotations in Java