随时随地技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)

结构:
java.lang.annotation
枚举 ElementType
java.lang.Objectjava.lang.Enum<ElementType>java.lang.annotation.ElementType
所有已实现的接口:
Serializable,Comparable<ElementType>
描述:
public enum ElementType
extends Enum<ElementType>
程序元素类型。此枚举类型的常量提供了 Java 程序中声明的元素的简单分类。
这些常量与 Target 元注释类型一起使用,以指定在什么情况下使用注释类型是合法的。
从以下版本开始:
1.5
枚举常量:
1、public static final ElementTypeTYPE 类、接口(包括注释类型)或枚举声明
2、public static final ElementTypeFIELD 字段声明(包括枚举常量)
3、public static final ElementTypeMETHOD 方法声明
4、public static final ElementTypePARAMETER 参数声明
5、public static final ElementTypeCONSTRUCTOR 构造方法声明
6、public static final ElementTypeLOCAL_VARIABLE 局部变量声明
7、public static final ElementTypeANNOTATION_TYPE 注释类型声明
8、public static final ElementTypePACKAGE 包声明
方法详细:
1、public static final ElementType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for(ElementType c : ElementType.values())System.out.println(c);
返回:
an array containing the constants of this enum type, in the order they are declared
2、public static ElementTypevalueOf(String name)
返回带有指定名称的该类型的枚举常量。字符串必须与用于声明该类型的枚举常量的标识符完全匹配。(不允许有多余的空格。)
参数:
指定要返回的枚举常量的名称。 -
返回:
返回带有指定名称的枚举常量
抛出:
如果该枚举类型没有带有指定名称的常量, - 则抛出 IllegalArgumentException