![JAR search and dependency download from the Maven repository](/logo.png)
com.avaje.ebean.enhance.agent.MethodSetEmbeddedLoaded Maven / Gradle / Ivy
package com.avaje.ebean.enhance.agent;
import com.avaje.ebean.enhance.asm.ClassVisitor;
import com.avaje.ebean.enhance.asm.Label;
import com.avaje.ebean.enhance.asm.MethodVisitor;
import com.avaje.ebean.enhance.asm.Opcodes;
import java.util.List;
/**
* Generate the _ebean_setEmbeddedLoaded() method.
*/
public class MethodSetEmbeddedLoaded implements Opcodes, EnhanceConstants {
/**
* Generate the _ebean_setEmbeddedLoaded() method.
*
*
* public void _ebean_setEmbeddedLoaded() {
* // for each embedded bean field...
* entityBeanIntercept.setEmbeddedLoaded(embeddedBeanField);
* }
*
*/
public static void addMethod(ClassVisitor cv, ClassMeta classMeta) {
String className = classMeta.getClassName();
MethodVisitor mv;
mv = cv.visitMethod(ACC_PUBLIC, "_ebean_setEmbeddedLoaded", "()V", null, null);
mv.visitCode();
Label labelBegin = null;
List allFields = classMeta.getAllFields();
for (int i = 0; i < allFields.size(); i++) {
FieldMeta fieldMeta = allFields.get(i);
if (fieldMeta.isEmbedded()){
Label l0 = new Label();
if (labelBegin == null){
labelBegin = l0;
}
mv.visitLabel(l0);
mv.visitLineNumber(0, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, className, INTERCEPT_FIELD, L_INTERCEPT);
mv.visitVarInsn(ALOAD, 0);
fieldMeta.appendSwitchGet(mv, classMeta, false);
mv.visitMethodInsn(INVOKEVIRTUAL, C_INTERCEPT, "setEmbeddedLoaded", "(Ljava/lang/Object;)V", false);
}
}
Label l2 = new Label();
if (labelBegin == null){
labelBegin = l2;
}
mv.visitLabel(l2);
mv.visitLineNumber(1, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
mv.visitLocalVariable("this", "L"+className+";", null, labelBegin, l3, 0);
mv.visitMaxs(2, 1);
mv.visitEnd();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy