package com.qianwen.core.http; import java.io.IOException; import java.util.function.BiConsumer; import java.util.function.Consumer; import okhttp3.Call; import okhttp3.Request; public class AsyncCall { private static final Consumer DEFAULT_CONSUMER = r -> { }; private static final BiConsumer DEFAULT_FAIL_CONSUMER = (r, e) -> { }; private final Call call; private Consumer successConsumer = DEFAULT_CONSUMER; private Consumer responseConsumer = DEFAULT_CONSUMER; private BiConsumer failedBiConsumer = DEFAULT_FAIL_CONSUMER; /* JADX INFO: Access modifiers changed from: package-private */ public AsyncCall(Call call) { this.call = call; } public void onSuccessful(Consumer consumer) { this.successConsumer = consumer; execute(); } public void onResponse(Consumer consumer) { this.responseConsumer = consumer; execute(); } public AsyncCall onFailed(BiConsumer biConsumer) { this.failedBiConsumer = biConsumer; return this; } private void execute() { this.call.enqueue(new AsyncCallback(this)); } /* JADX INFO: Access modifiers changed from: package-private */ public void onResponse(HttpResponse httpResponse) { this.responseConsumer.accept(httpResponse); } /* JADX INFO: Access modifiers changed from: package-private */ public void onSuccessful(HttpResponse httpResponse) { this.successConsumer.accept(httpResponse); } /* JADX INFO: Access modifiers changed from: package-private */ public void onFailure(Request request, IOException e) { this.failedBiConsumer.accept(request, e); } }