use of act.asm.FieldVisitor in project actframework by actframework.
the class ConfigurationByteCodeScanner method byteCodeVisitor.
@Override
public ByteCodeVisitor byteCodeVisitor() {
return new ByteCodeVisitor() {
@Override
public FieldVisitor visitField(int access, final String name, String desc, String signature, Object value) {
FieldVisitor fv = super.visitField(access, name, desc, signature, value);
boolean isStatic = AsmTypes.isStatic(access);
if (!isStatic) {
return fv;
}
final String fieldName = name;
return new FieldVisitor(ASM5, fv) {
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
AnnotationVisitor av = super.visitAnnotation(desc, visible);
if (S.eq(CONF_DESC, desc)) {
return new AnnotationVisitor(ASM5, av) {
@Override
public void visit(String name, Object value) {
staticConfigurationFields.put(fieldName, S.string(value));
super.visit(name, value);
}
};
}
return av;
}
};
}
};
}
use of act.asm.FieldVisitor in project act-ebean by actframework.
the class TimestampAuditorEnhancer method visitField.
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
FieldVisitor fv = super.visitField(access, name, desc, signature, value);
if (null == createdAt && null == lastModifiedAt) {
return fv;
}
final boolean isCreatedAt = name.equals(createdAt);
final boolean isLastModified = !isCreatedAt && name.equals(lastModifiedAt);
if (!isCreatedAt && !isLastModified) {
return fv;
}
return new FieldVisitor(ASM5, fv) {
@Override
public void visitEnd() {
AnnotationVisitor av;
if (isCreatedAt) {
av = fv.visitAnnotation("Lcom/avaje/ebean/annotation/WhenCreated;", true);
} else {
av = fv.visitAnnotation("Lcom/avaje/ebean/annotation/WhenModified;", true);
}
av.visitEnd();
super.visitEnd();
}
};
}
Aggregations