yangys
2024-03-27 e48aa2ac8dea1be5db11c63edf0b912c4ad5ce65
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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;
 
/* loaded from: blade-starter-http-9.3.0.0-SNAPSHOT.jar:org/springblade/core/http/AsyncCall.class */
public class AsyncCall {
    private static final Consumer<ResponseSpec> DEFAULT_CONSUMER = r -> {
    };
    private static final BiConsumer<Request, IOException> DEFAULT_FAIL_CONSUMER = (r, e) -> {
        
    };
    private final Call call;
    private Consumer<ResponseSpec> successConsumer = DEFAULT_CONSUMER;
    private Consumer<ResponseSpec> responseConsumer = DEFAULT_CONSUMER;
    private BiConsumer<Request, IOException> failedBiConsumer = DEFAULT_FAIL_CONSUMER;
 
    /* JADX INFO: Access modifiers changed from: package-private */
    public AsyncCall(Call call) {
        this.call = call;
    }
 
    public void onSuccessful(Consumer<ResponseSpec> consumer) {
        this.successConsumer = consumer;
        execute();
    }
 
    public void onResponse(Consumer<ResponseSpec> consumer) {
        this.responseConsumer = consumer;
        execute();
    }
 
    public AsyncCall onFailed(BiConsumer<Request, IOException> 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);
    }
}