com.zving.framework.thirdparty.asm.tree.FieldNode Maven / Gradle / Ivy
package com.zving.framework.thirdparty.asm.tree;
import com.zving.framework.thirdparty.asm.AnnotationVisitor;
import com.zving.framework.thirdparty.asm.Attribute;
import com.zving.framework.thirdparty.asm.ClassVisitor;
import com.zving.framework.thirdparty.asm.FieldVisitor;
import java.util.ArrayList;
import java.util.List;
public class FieldNode extends FieldVisitor {
public Object value;
public List visibleAnnotations;
public List invisibleAnnotations;
public List attrs;
public int access;
public String name;
public String desc;
public String signature;
public FieldNode(int access, String name, String desc, String signature, Object value) {
this(262144, access, name, desc, signature, value);
}
public FieldNode(int api, int access, String name, String desc, String signature, Object value) {
super(api);
this.access = access;
this.name = name;
this.desc = desc;
this.signature = signature;
this.value = value;
}
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
AnnotationNode an = new AnnotationNode(desc);
if (visible) {
if (this.visibleAnnotations == null) {
this.visibleAnnotations = new ArrayList(1);
}
this.visibleAnnotations.add(an);
} else {
if (this.invisibleAnnotations == null) {
this.invisibleAnnotations = new ArrayList(1);
}
this.invisibleAnnotations.add(an);
}
return an;
}
public void visitAttribute(Attribute attr) {
if (this.attrs == null) {
this.attrs = new ArrayList(1);
}
this.attrs.add(attr);
}
public void visitEnd() {
}
public void check(int api) {
}
public void accept(ClassVisitor cv) {
FieldVisitor fv = cv.visitField(this.access, this.name, this.desc, this.signature, this.value);
if (fv == null) {
return;
}
int n = this.visibleAnnotations == null ? 0 : this.visibleAnnotations.size();
for (int i = 0; i < n; i++) {
AnnotationNode an = (AnnotationNode) this.visibleAnnotations.get(i);
an.accept(fv.visitAnnotation(an.desc, true));
}
n = this.invisibleAnnotations == null ? 0 : this.invisibleAnnotations.size();
for (int i = 0; i < n; i++) {
AnnotationNode an = (AnnotationNode) this.invisibleAnnotations.get(i);
an.accept(fv.visitAnnotation(an.desc, false));
}
n = this.attrs == null ? 0 : this.attrs.size();
for (int i = 0; i < n; i++) {
fv.visitAttribute((Attribute) this.attrs.get(i));
}
fv.visitEnd();
}
}