what-the-bank/sources/retrofit2/adapter/rxjava3/RxJava3CallAdapterFactory.java

91 lines
3.5 KiB
Java

package retrofit2.adapter.rxjava3;
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import o.AbstractC13155fSc;
import o.AbstractC13159fSg;
import o.AbstractC13163fSk;
import o.AbstractC13173fSu;
import o.AbstractC13175fSw;
import o.fRY;
import retrofit2.CallAdapter;
import retrofit2.Response;
import retrofit2.Retrofit;
/* loaded from: classes.dex */
public final class RxJava3CallAdapterFactory extends CallAdapter.Factory {
private final boolean isAsync;
private final AbstractC13173fSu scheduler;
public static RxJava3CallAdapterFactory create() {
return new RxJava3CallAdapterFactory(null, true);
}
public static RxJava3CallAdapterFactory createSynchronous() {
return new RxJava3CallAdapterFactory(null, false);
}
public static RxJava3CallAdapterFactory createWithScheduler(AbstractC13173fSu abstractC13173fSu) {
if (abstractC13173fSu == null) {
throw new NullPointerException("scheduler == null");
}
return new RxJava3CallAdapterFactory(abstractC13173fSu, false);
}
private RxJava3CallAdapterFactory(AbstractC13173fSu abstractC13173fSu, boolean z) {
this.scheduler = abstractC13173fSu;
this.isAsync = z;
}
@Override // retrofit2.CallAdapter.Factory
public final CallAdapter<?, ?> get(Type type, Annotation[] annotationArr, Retrofit retrofit) {
Type type2;
boolean z;
boolean z2;
Class<?> rawType = getRawType(type);
if (rawType == fRY.class) {
return new RxJava3CallAdapter(Void.class, this.scheduler, this.isAsync, false, true, false, false, false, true);
}
boolean z3 = rawType == AbstractC13155fSc.class;
boolean z4 = rawType == AbstractC13175fSw.class;
boolean z5 = rawType == AbstractC13159fSg.class;
if (rawType != AbstractC13163fSk.class && !z3 && !z4 && !z5) {
return null;
}
if (!(type instanceof ParameterizedType)) {
String str = !z3 ? !z4 ? z5 ? "Maybe" : "Observable" : "Single" : "Flowable";
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(" return type must be parameterized as ");
sb.append(str);
sb.append("<Foo> or ");
sb.append(str);
sb.append("<? extends Foo>");
throw new IllegalStateException(sb.toString());
}
Type parameterUpperBound = getParameterUpperBound(0, (ParameterizedType) type);
Class<?> rawType2 = getRawType(parameterUpperBound);
if (rawType2 == Response.class) {
if (!(parameterUpperBound instanceof ParameterizedType)) {
throw new IllegalStateException("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
}
type2 = getParameterUpperBound(0, (ParameterizedType) parameterUpperBound);
z2 = false;
z = false;
} else if (rawType2 != Result.class) {
type2 = parameterUpperBound;
z = true;
z2 = false;
} else {
if (!(parameterUpperBound instanceof ParameterizedType)) {
throw new IllegalStateException("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
}
type2 = getParameterUpperBound(0, (ParameterizedType) parameterUpperBound);
z2 = true;
z = false;
}
return new RxJava3CallAdapter(type2, this.scheduler, this.isAsync, z2, z, z3, z4, z5, false);
}
}