Search in sources :

Example 16 with MethodInfo

use of org.powermock.api.mockito.repackaged.cglib.core.MethodInfo in project powermock by powermock.

the class BeanMapEmitter method generateGet.

private void generateGet(Class type, final Map getters) {
    final CodeEmitter e = begin_method(Constants.ACC_PUBLIC, BEAN_MAP_GET, null);
    e.load_arg(0);
    e.checkcast(Type.getType(type));
    e.load_arg(1);
    e.checkcast(Constants.TYPE_STRING);
    EmitUtils.string_switch(e, getNames(getters), Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {

        public void processCase(Object key, Label end) {
            PropertyDescriptor pd = (PropertyDescriptor) getters.get(key);
            MethodInfo method = ReflectUtils.getMethodInfo(pd.getReadMethod());
            e.invoke(method);
            e.box(method.getSignature().getReturnType());
            e.return_value();
        }

        public void processDefault() {
            e.aconst_null();
            e.return_value();
        }
    });
    e.end_method();
}
Also used : CodeEmitter(org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter) PropertyDescriptor(java.beans.PropertyDescriptor) Label(org.powermock.api.mockito.repackaged.asm.Label) MethodInfo(org.powermock.api.mockito.repackaged.cglib.core.MethodInfo) ObjectSwitchCallback(org.powermock.api.mockito.repackaged.cglib.core.ObjectSwitchCallback)

Aggregations

MethodInfo (org.powermock.api.mockito.repackaged.cglib.core.MethodInfo)16 CodeEmitter (org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter)13 Iterator (java.util.Iterator)10 Label (org.powermock.api.mockito.repackaged.asm.Label)7 Signature (org.powermock.api.mockito.repackaged.cglib.core.Signature)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Block (org.powermock.api.mockito.repackaged.cglib.core.Block)3 Local (org.powermock.api.mockito.repackaged.cglib.core.Local)3 ObjectSwitchCallback (org.powermock.api.mockito.repackaged.cglib.core.ObjectSwitchCallback)3 PropertyDescriptor (java.beans.PropertyDescriptor)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ClassEmitter (org.powermock.api.mockito.repackaged.cglib.core.ClassEmitter)1 ClassInfo (org.powermock.api.mockito.repackaged.cglib.core.ClassInfo)1 CodeGenerationException (org.powermock.api.mockito.repackaged.cglib.core.CodeGenerationException)1