package j.q.a;

import e.a.n;
import e.a.o;
import j.c;
import j.m;
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.annotation.Nullable;

/* JADX INFO: compiled from: RxJava2CallAdapterFactory.java */
/* JADX INFO: loaded from: classes.dex */
public final class h extends c.a {

    @Nullable
    private final n a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final boolean f4427b;

    private h(@Nullable n nVar, boolean z) {
        this.a = nVar;
        this.f4427b = z;
    }

    public static h d() {
        return new h(null, false);
    }

    @Override // j.c.a
    public j.c<?, ?> a(Type type, Annotation[] annotationArr, j.n nVar) {
        Type typeB;
        boolean z;
        boolean z2;
        Class<?> clsC = c.a.c(type);
        if (clsC == e.a.b.class) {
            return new g(Void.class, this.a, this.f4427b, false, true, false, false, false, true);
        }
        boolean z3 = clsC == e.a.e.class;
        boolean z4 = clsC == o.class;
        boolean z5 = clsC == e.a.f.class;
        if (clsC != e.a.h.class && !z3 && !z4 && !z5) {
            return null;
        }
        if (!(type instanceof ParameterizedType)) {
            String str = !z3 ? !z4 ? z5 ? "Maybe" : "Observable" : "Single" : "Flowable";
            throw new IllegalStateException(str + " return type must be parameterized as " + str + "<Foo> or " + str + "<? extends Foo>");
        }
        Type typeB2 = c.a.b(0, (ParameterizedType) type);
        Class<?> clsC2 = c.a.c(typeB2);
        if (clsC2 == m.class) {
            if (!(typeB2 instanceof ParameterizedType)) {
                throw new IllegalStateException("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
            }
            typeB = c.a.b(0, (ParameterizedType) typeB2);
            z2 = false;
            z = false;
        } else if (clsC2 != e.class) {
            typeB = typeB2;
            z = true;
            z2 = false;
        } else {
            if (!(typeB2 instanceof ParameterizedType)) {
                throw new IllegalStateException("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
            }
            typeB = c.a.b(0, (ParameterizedType) typeB2);
            z2 = true;
            z = false;
        }
        return new g(typeB, this.a, this.f4427b, z2, z, z3, z4, z5, false);
    }
}
