Search in sources :

Example 6 with FieldVisitor

use of org.simpleflatmapper.ow2asm.FieldVisitor in project SimpleFlatMapper by arnaudroger.

the class MapperAsmBuilder method declareMapperFields.

private static <S, T> void declareMapperFields(ClassWriter cw, FieldMapper<S, T> mapper, int index) {
    if (mapper == null)
        return;
    FieldVisitor fv;
    Type mapperClass = AsmUtils.findClosestPublicTypeExposing(mapper.getClass(), FieldMapper.class);
    fv = cw.visitField(ACC_PRIVATE + ACC_FINAL, "fieldMapper" + index, toTargetTypeDeclaration(AsmUtils.toAsmType(mapperClass)), toTargetTypeDeclaration(AsmUtils.toGenericAsmType(mapperClass)), null);
    fv.visitEnd();
}
Also used : Type(java.lang.reflect.Type) FieldVisitor(org.simpleflatmapper.ow2asm.FieldVisitor)

Example 7 with FieldVisitor

use of org.simpleflatmapper.ow2asm.FieldVisitor in project SimpleFlatMapper by arnaudroger.

the class InstantiatorBuilder method appendGetters.

private static <S> void appendGetters(Map<Parameter, Getter<? super S, ?>> injections, ClassWriter cw) {
    FieldVisitor fv;
    for (Entry<Parameter, Getter<? super S, ?>> entry : injections.entrySet()) {
        GetterCall getterCall = getGetterCall(entry.getKey().getType(), entry.getValue().getClass());
        fv = cw.visitField(ACC_FINAL, "getter_" + entry.getKey().getName(), AsmUtils.toTargetTypeDeclaration(getterCall.getterType), null, null);
        fv.visitEnd();
    }
}
Also used : Getter(org.simpleflatmapper.reflect.Getter) Parameter(org.simpleflatmapper.reflect.Parameter) FieldVisitor(org.simpleflatmapper.ow2asm.FieldVisitor)

Aggregations

FieldVisitor (org.simpleflatmapper.ow2asm.FieldVisitor)7 ClassWriter (org.simpleflatmapper.ow2asm.ClassWriter)3 Type (java.lang.reflect.Type)2 MethodVisitor (org.simpleflatmapper.ow2asm.MethodVisitor)1 Getter (org.simpleflatmapper.reflect.Getter)1 Parameter (org.simpleflatmapper.reflect.Parameter)1