本文整理汇总了Java中org.objectweb.asm.AnnotationVisitor.visitEnum方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationVisitor.visitEnum方法的具体用法?Java AnnotationVisitor.visitEnum怎么用?Java AnnotationVisitor.visitEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.AnnotationVisitor
的用法示例。
在下文中一共展示了AnnotationVisitor.visitEnum方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitAnnotationValue
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
private void visitAnnotationValue(AnnotationVisitor annotationVisitor, AnnotationValue<?> value) {
String name = value.getName();
if (value instanceof EnumAnnotationValue) {
annotationVisitor.visitEnum(name, ((EnumAnnotationValue) value).getTypeDesc(), (String) value.getValue());
} else if (value instanceof SimpleAnnotationValue) {
annotationVisitor.visit(name, value.getValue());
} else if (value instanceof ArrayAnnotationValue) {
AnnotationVisitor arrayVisitor = annotationVisitor.visitArray(name);
AnnotationValue<?>[] values = ((ArrayAnnotationValue) value).getValue();
for (AnnotationValue<?> annotationValue : values) {
visitAnnotationValue(arrayVisitor, annotationValue);
}
arrayVisitor.visitEnd();
} else if (value instanceof AnnotationAnnotationValue) {
AnnotationMember annotation = ((AnnotationAnnotationValue) value).getValue();
AnnotationVisitor annVisitor = annotationVisitor.visitAnnotation(name, annotation.getName());
visitAnnotationValues(annotation, annVisitor);
}
}
示例2: visitAnnotationValues
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
private void visitAnnotationValues(Annotation annotation, AnnotationVisitor annotationVisitor) {
for (Method method : annotation.annotationType().getDeclaredMethods()) {
String name = method.getName();
Class<?> returnType = method.getReturnType();
if (returnType.isEnum()) {
annotationVisitor.visitEnum(name, Type.getType(returnType).getDescriptor(), getAnnotationParameterValue(annotation, method).toString());
} else if (returnType.isArray() && !PRIMITIVE_TYPES.contains(returnType.getComponentType())) {
AnnotationVisitor arrayVisitor = annotationVisitor.visitArray(name);
Object[] elements = (Object[]) getAnnotationParameterValue(annotation, method);
visitArrayElements(arrayVisitor, returnType.getComponentType(), elements);
arrayVisitor.visitEnd();
} else if (returnType.equals(Class.class)) {
Class<?> clazz = (Class<?>) getAnnotationParameterValue(annotation, method);
annotationVisitor.visit(name, Type.getType(clazz));
} else if (returnType.isAnnotation()) {
Annotation nestedAnnotation = (Annotation) getAnnotationParameterValue(annotation, method);
AnnotationVisitor nestedAnnotationVisitor = annotationVisitor.visitAnnotation(name, Type.getType(returnType).getDescriptor());
visitAnnotationValues(nestedAnnotation, nestedAnnotationVisitor);
nestedAnnotationVisitor.visitEnd();
} else {
annotationVisitor.visit(name, getAnnotationParameterValue(annotation, method));
}
}
}
示例3: accept
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
/**
* Makes the given visitor visit a given annotation value.
*
* @param av
* an annotation visitor. Maybe <tt>null</tt>.
* @param name
* the value name.
* @param value
* the actual value.
*/
static void accept(final AnnotationVisitor av, final String name,
final Object value) {
if (av != null) {
if (value instanceof String[]) {
String[] typeconst = (String[]) value;
av.visitEnum(name, typeconst[0], typeconst[1]);
} else if (value instanceof AnnotationNode) {
AnnotationNode an = (AnnotationNode) value;
an.accept(av.visitAnnotation(name, an.desc));
} else if (value instanceof List) {
AnnotationVisitor v = av.visitArray(name);
if (v != null) {
List<?> array = (List<?>) value;
for (int j = 0; j < array.size(); ++j) {
accept(v, null, array.get(j));
}
v.visitEnd();
}
} else {
av.visit(name, value);
}
}
}
示例4: begin
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
@Override
public void begin(final String nm, final Attributes attrs) {
AnnotationVisitor av = (AnnotationVisitor) peek();
if (av != null) {
av.visitEnum(attrs.getValue("name"), attrs.getValue("desc"),
attrs.getValue("value"));
}
}
示例5: addAnnotation
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
private static void addAnnotation(String name, Class<?> annotationMethodType, String typeDesc, AnnotationVisitor av,
Object value)
throws IllegalAccessException, InvocationTargetException {
if (Enum.class.isAssignableFrom(annotationMethodType)) {
av.visitEnum(name, typeDesc, value.toString());
} else if (annotationMethodType.isAnnotation()) {
@SuppressWarnings("unchecked")
Class<? extends Annotation> annType = (Class<? extends Annotation>) annotationMethodType;
AnnotationVisitor annotationVisitor = av.visitAnnotation(name, typeDesc);
addAnnotationTree(annotationVisitor, (Annotation) value, annType);
annotationVisitor.visitEnd();
} else {
av.visit(name, value);
}
}