package com.ubtrobot.retrofit.adapter.urest; import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import retrofit2.Call; import retrofit2.CallAdapter; import retrofit2.Retrofit; /* loaded from: classes2.dex */ public class URestCallAdapterFactory extends CallAdapter.Factory { private static final class ResponseCallAdapter implements CallAdapter> { Retrofit a; Type b; ResponseCallAdapter(Retrofit retrofit, Type type) { this.a = retrofit; this.b = type; } @Override // retrofit2.CallAdapter public Type responseType() { return this.b; } @Override // retrofit2.CallAdapter public URestCall adapt(Call call) { return new URestCall<>(this.a, call); } } private URestCallAdapterFactory() { } private Type a(Type type) { if (type instanceof ParameterizedType) { return CallAdapter.Factory.getParameterUpperBound(0, (ParameterizedType) type); } throw new IllegalArgumentException("Call return type must be parameterized as RestCall or RestCall"); } public static URestCallAdapterFactory create() { return new URestCallAdapterFactory(); } @Override // retrofit2.CallAdapter.Factory public CallAdapter get(Type type, Annotation[] annotationArr, Retrofit retrofit) { if (CallAdapter.Factory.getRawType(type) != URestCall.class) { return null; } return new ResponseCallAdapter(retrofit, a(type)); } }