package d.c.a;

import d.c.a.o;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Type;

/* JADX INFO: compiled from: ServiceMethod.java */
/* JADX INFO: loaded from: classes.dex */
public final class r {
    public f a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public String f2441c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public boolean f2442d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public o<?>[] f2443e;

    /* JADX INFO: compiled from: ServiceMethod.java */
    public static final class a {
        public d a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public Method f2444b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public Annotation[] f2445c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public Annotation[][] f2446d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public Type[] f2447e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public f f2448f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public String f2449g = "";

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        public String f2450h = "";

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public boolean f2451i = false;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        public o<?>[] f2452j;

        public a(d dVar, Method method) {
            this.a = dVar;
            this.f2444b = method;
            this.f2445c = method.getAnnotations();
            this.f2446d = method.getParameterAnnotations();
            this.f2447e = method.getGenericParameterTypes();
        }

        public r a() {
            o<?> bVar;
            Type genericReturnType = this.f2444b.getGenericReturnType();
            if (c.n.a.F(genericReturnType)) {
                throw b(null, "Method return type must not include a type variable or wildcard: %s", genericReturnType);
            }
            try {
                this.f2448f = this.a.a(genericReturnType, this.f2444b.getAnnotations());
                this.f2449g = this.f2444b.getDeclaringClass().getSimpleName();
                this.f2450h = this.f2444b.getName();
                Annotation[] annotationArr = this.f2445c;
                int length = annotationArr.length;
                int i2 = 0;
                while (true) {
                    if (i2 >= length) {
                        break;
                    }
                    if (annotationArr[i2] instanceof d.c.a.v.d) {
                        this.f2451i = true;
                        break;
                    }
                    i2++;
                }
                int length2 = this.f2446d.length;
                this.f2452j = new o[length2];
                for (int i3 = 0; i3 < length2; i3++) {
                    Type type = this.f2447e[i3];
                    if (c.n.a.F(type)) {
                        throw c(i3, "Parameter type must not include a type variable or wildcard: %s", type);
                    }
                    Annotation[] annotationArr2 = this.f2446d[i3];
                    o<?>[] oVarArr = this.f2452j;
                    Class<?> clsY = c.n.a.y(type);
                    if (annotationArr2 != null && annotationArr2.length != 0) {
                        for (Annotation annotation : annotationArr2) {
                            if (annotation instanceof d.c.a.v.a) {
                                bVar = new o.a<>(clsY);
                            } else if ((annotation instanceof d.c.a.v.b) || (annotation instanceof d.c.a.v.e) || (annotation instanceof d.c.a.v.c)) {
                                bVar = new o.c<>(annotation, clsY);
                            }
                        }
                        throw c(i3, "No support annotation found.", new Object[0]);
                    }
                    bVar = new o.b<>(clsY);
                    oVarArr[i3] = bVar;
                }
                return new r(this);
            } catch (RuntimeException e2) {
                throw b(e2, "Unable to create call adapter for %s", genericReturnType);
            }
        }

        public final RuntimeException b(Throwable th, String str, Object... objArr) {
            StringBuilder sbD = d.b.a.a.a.D(String.format(str, objArr), "\n    for method ");
            sbD.append(this.f2444b.getDeclaringClass().getSimpleName());
            sbD.append(".");
            sbD.append(this.f2444b.getName());
            return new IllegalArgumentException(sbD.toString(), th);
        }

        public final RuntimeException c(int i2, String str, Object... objArr) {
            StringBuilder sbD = d.b.a.a.a.D(str, " (parameter #");
            sbD.append(i2 + 1);
            sbD.append(")");
            return b(null, sbD.toString(), objArr);
        }
    }

    public r(a aVar) {
        this.a = aVar.f2448f;
        this.f2440b = aVar.f2449g;
        this.f2441c = aVar.f2450h;
        this.f2442d = aVar.f2451i;
        this.f2443e = aVar.f2452j;
    }
}
