package defpackage;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;

/* renamed from: ᵹᵷ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C5082 {

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final HashMap f19006;

    public C5082(int i) {
        switch (i) {
            case 2:
                this.f19006 = new HashMap();
                new HashMap();
                break;
            case 3:
                this.f19006 = new HashMap();
                break;
            default:
                this.f19006 = new HashMap();
                break;
        }
    }

    public C5082(C3480 c3480) {
        this.f19006 = c3480.f13034;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public C2104 m10554(Class cls) throws NoSuchMethodException, SecurityException {
        Method declaredMethod;
        InterfaceC2246[] interfaceC2246Arr;
        int i;
        Class cls2 = cls;
        C2104 c2104 = new C2104();
        c2104.f8326 = new ArrayList();
        c2104.f8327 = (InterfaceC2846) ᵿᵧ.ᵯٴᵦ(cls2, InterfaceC2846.class);
        ArrayList arrayList = new ArrayList();
        ᵿᵧ.ᵡʠ(cls2, arrayList);
        int size = arrayList.size();
        Method[] methodArr = new Method[size];
        arrayList.toArray(methodArr);
        int i2 = 0;
        int i3 = 0;
        while (i3 < size) {
            Method method = methodArr[i3];
            int i4 = i2;
            while (true) {
                if (i4 < size) {
                    Method method2 = methodArr[i4];
                    if (!method.getDeclaringClass().equals(method2.getDeclaringClass()) && method.getDeclaringClass().isAssignableFrom(method2.getDeclaringClass()) && method.getName().equals(method2.getName())) {
                        Class<?>[] parameterTypes = method.getParameterTypes();
                        Class<?>[] parameterTypes2 = method2.getParameterTypes();
                        for (int i5 = i2; i5 < parameterTypes2.length; i5++) {
                            if (!parameterTypes[i5].equals(parameterTypes2[i5])) {
                                break;
                            }
                        }
                        break;
                    }
                    i4++;
                } else {
                    InterfaceC1095 interfaceC1095 = (InterfaceC1095) ᵿᵧ.ᵯٴᵦ(method, InterfaceC1095.class);
                    if (!interfaceC1095.enabled() || method == null || ᵿᵧ.ᵯٴᵦ(method, InterfaceC1095.class) == null) {
                        break;
                    }
                    boolean z = true;
                    if (method.getParameterTypes().length != 1) {
                        System.out.println("Found no or more than one parameter in messageHandler [" + method.getName() + "]. A messageHandler must define exactly one parameter");
                    } else {
                        InterfaceC5242 interfaceC5242 = (InterfaceC5242) ᵿᵧ.ᵯٴᵦ(method, InterfaceC5242.class);
                        if (interfaceC5242 != null && !C2283.class.isAssignableFrom(method.getParameterTypes()[i2])) {
                            System.out.println("Message envelope configured but no subclass of MessageEnvelope found as parameter");
                        } else if (interfaceC5242 == null || interfaceC5242.messages().length != 0) {
                            Class superclass = cls2;
                            while (true) {
                                if (superclass.equals(method.getDeclaringClass())) {
                                    declaredMethod = null;
                                    break;
                                }
                                try {
                                    declaredMethod = superclass.getDeclaredMethod(method.getName(), method.getParameterTypes());
                                    break;
                                } catch (NoSuchMethodException unused) {
                                    superclass = superclass.getSuperclass();
                                }
                            }
                            if (declaredMethod != null) {
                                method = declaredMethod;
                            }
                            if (interfaceC1095.filters().length == 0) {
                                interfaceC2246Arr = null;
                            } else {
                                interfaceC2246Arr = new InterfaceC2246[interfaceC1095.filters().length];
                                InterfaceC3078[] interfaceC3078ArrFilters = interfaceC1095.filters();
                                int length = interfaceC3078ArrFilters.length;
                                int i6 = i2;
                                int i7 = i6;
                                while (i6 < length) {
                                    InterfaceC3078 interfaceC3078 = interfaceC3078ArrFilters[i6];
                                    Class clsValue = interfaceC3078.value();
                                    boolean z2 = z;
                                    HashMap map = this.f19006;
                                    InterfaceC2246 interfaceC2246 = (InterfaceC2246) map.get(clsValue);
                                    if (interfaceC2246 == null) {
                                        try {
                                            interfaceC2246 = (InterfaceC2246) interfaceC3078.value().newInstance();
                                            map.put(interfaceC3078.value(), interfaceC2246);
                                        } catch (Exception e) {
                                            C1260.m3814(e);
                                            return null;
                                        }
                                    }
                                    interfaceC2246Arr[i7] = interfaceC2246;
                                    i7++;
                                    i6++;
                                    z = z2;
                                }
                            }
                            boolean z3 = z;
                            i = 0;
                            if (interfaceC2246Arr == null) {
                                interfaceC2246Arr = new InterfaceC2246[0];
                            }
                            InterfaceC5242 interfaceC52422 = (InterfaceC5242) ᵿᵧ.ᵯٴᵦ(method, InterfaceC5242.class);
                            Class[] clsArrMessages = interfaceC52422 != null ? interfaceC52422.messages() : method.getParameterTypes();
                            method.setAccessible(z3);
                            HashMap map2 = new HashMap();
                            map2.put("handler", method);
                            if (interfaceC1095.condition().length() > 0) {
                                if (AbstractC2449.f9565 == null) {
                                    ᵹˉᵞ.ᵳٴᵶ("A handler uses an EL filter but no EL implementation is available.");
                                    return null;
                                }
                                InterfaceC2246[] interfaceC2246Arr2 = new InterfaceC2246[interfaceC2246Arr.length + (z3 ? 1 : 0)];
                                for (int i8 = 0; i8 < interfaceC2246Arr.length; i8++) {
                                    interfaceC2246Arr2[i8] = interfaceC2246Arr[i8];
                                }
                                interfaceC2246Arr2[interfaceC2246Arr.length] = new C0787();
                                interfaceC2246Arr = interfaceC2246Arr2;
                            }
                            map2.put("filter", interfaceC2246Arr);
                            String strCondition = interfaceC1095.condition();
                            if (!strCondition.trim().startsWith("${") && !strCondition.trim().startsWith("#{")) {
                                strCondition = AbstractC4486.m9550("${", strCondition, "}");
                            }
                            map2.put("condition", strCondition);
                            map2.put("priority", Integer.valueOf(interfaceC1095.priority()));
                            map2.put("invocation", interfaceC1095.invocation());
                            map2.put("invocationMode", interfaceC1095.delivery());
                            map2.put("envelope", Boolean.valueOf(interfaceC52422 != null));
                            map2.put("subtypes", Boolean.valueOf(!interfaceC1095.rejectSubtypes()));
                            map2.put("listener", c2104);
                            map2.put("synchronized", Boolean.valueOf(ᵿᵧ.ᵯٴᵦ(method, InterfaceC3975.class) != null));
                            map2.put("messages", clsArrMessages);
                            c2104.f8326.add(new C2007(map2));
                        } else {
                            System.out.println("Message envelope configured but message types defined for handler");
                        }
                    }
                }
            }
            i = i2;
            i3++;
            i2 = i;
            cls2 = cls;
        }
        return c2104;
    }
}
