本文整理匯總了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);
}
}