package l;

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 l.c;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;

/* JADX INFO: compiled from: CompletableFutureCallAdapterFactory.java */
/* JADX INFO: loaded from: classes.dex */
@IgnoreJRERequirement
public final class g extends c.a {
    public static final c.a a = new g();

    /* JADX INFO: compiled from: CompletableFutureCallAdapterFactory.java */
    @IgnoreJRERequirement
    public static final class a<R> implements c<R, CompletableFuture<R>> {
        public final Type a;

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

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

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

    /* JADX INFO: compiled from: CompletableFutureCallAdapterFactory.java */
    @IgnoreJRERequirement
    public static final class b<R> implements c<R, CompletableFuture<b0<R>>> {
        public final Type a;

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

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

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

    @Override // l.c.a
    @Nullable
    public c<?, ?> a(Type type, Annotation[] annotationArr, c0 c0Var) {
        if (g0.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 = g0.e(0, (ParameterizedType) type);
        if (g0.f(typeE) != b0.class) {
            return new a(typeE);
        }
        if (typeE instanceof ParameterizedType) {
            return new b(g0.e(0, (ParameterizedType) typeE));
        }
        throw new IllegalStateException("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
    }
}
