package g.i0.j;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* JADX INFO: loaded from: classes.dex */
public class e<T> {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Class<?> f6402a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final String f6403b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Class[] f6404c;

    public e(Class<?> cls, String str, Class... clsArr) {
        this.f6402a = cls;
        this.f6403b = str;
        this.f6404c = clsArr;
    }

    public final Method a(Class<?> cls) {
        Method method;
        Class<?> cls2;
        String str = this.f6403b;
        if (str == null) {
            return null;
        }
        try {
            method = cls.getMethod(str, this.f6404c);
        } catch (NoSuchMethodException unused) {
        }
        try {
            if ((method.getModifiers() & 1) == 0) {
                method = null;
            }
        } catch (NoSuchMethodException unused2) {
        }
        if (method == null || (cls2 = this.f6402a) == null || cls2.isAssignableFrom(method.getReturnType())) {
            return method;
        }
        return null;
    }

    public Object b(T t, Object... objArr) {
        Method methodA = a(t.getClass());
        if (methodA == null) {
            StringBuilder sbC = a.b.c.a.a.C("Method ");
            sbC.append(this.f6403b);
            sbC.append(" not supported for object ");
            sbC.append(t);
            throw new AssertionError(sbC.toString());
        }
        try {
            return methodA.invoke(t, objArr);
        } catch (IllegalAccessException e2) {
            AssertionError assertionError = new AssertionError("Unexpectedly could not call: " + methodA);
            assertionError.initCause(e2);
            throw assertionError;
        }
    }

    public Object c(T t, Object... objArr) {
        try {
            Method methodA = a(t.getClass());
            if (methodA == null) {
                return null;
            }
            try {
                return methodA.invoke(t, objArr);
            } catch (IllegalAccessException unused) {
                return null;
            }
        } catch (InvocationTargetException e2) {
            Throwable targetException = e2.getTargetException();
            if (targetException instanceof RuntimeException) {
                throw ((RuntimeException) targetException);
            }
            AssertionError assertionError = new AssertionError("Unexpected exception");
            assertionError.initCause(targetException);
            throw assertionError;
        }
    }

    public Object d(T t, Object... objArr) {
        try {
            return b(t, objArr);
        } catch (InvocationTargetException e2) {
            Throwable targetException = e2.getTargetException();
            if (targetException instanceof RuntimeException) {
                throw ((RuntimeException) targetException);
            }
            AssertionError assertionError = new AssertionError("Unexpected exception");
            assertionError.initCause(targetException);
            throw assertionError;
        }
    }
}
