package j;

import j.c;
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nullable;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;

/* JADX INFO: loaded from: classes.dex */
@IgnoreJRERequirement
public final class g extends c.a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final c.a f6894a = new g();

    @IgnoreJRERequirement
    public static final class a<R> implements c<R, CompletableFuture<R>> {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final Type f6895a;

        public a(Type type) {
            this.f6895a = type;
        }

        @Override // j.c
        public Type a() {
            return this.f6895a;
        }

        @Override // j.c
        public Object b(j.b bVar) {
            e eVar = new e(this, bVar);
            bVar.B(new f(this, eVar));
            return eVar;
        }
    }

    @IgnoreJRERequirement
    public static final class b<R> implements c<R, CompletableFuture<b0<R>>> {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final Type f6896a;

        public b(Type type) {
            this.f6896a = type;
        }

        @Override // j.c
        public Type a() {
            return this.f6896a;
        }

        @Override // j.c
        public Object b(j.b bVar) {
            h hVar = new h(this, bVar);
            bVar.B(new i(this, hVar));
            return hVar;
        }
    }

    @Override // j.c.a
    @Nullable
    public c<?, ?> a(Type type, Annotation[] annotationArr, d0 d0Var) {
        if (h0.f(type) != CompletableFuture.class) {
            return null;
        }
        if (!(type instanceof ParameterizedType)) {
            throw new IllegalStateException("CompletableFuture return type must be parameterized as CompletableFuture<Foo> or CompletableFuture<? extends Foo>");
        }
        Type typeE = h0.e(0, (ParameterizedType) type);
        if (h0.f(typeE) != b0.class) {
            return new a(typeE);
        }
        if (typeE instanceof ParameterizedType) {
            return new b(h0.e(0, (ParameterizedType) typeE));
        }
        throw new IllegalStateException("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
    }
}
