admin
2021-02-03 1981dee5aec45793d3c4ebdbc4e637528c71b3c5
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
package com.lcjian.library.okhttp.builder;
 
import com.lcjian.library.okhttp.request.RequestCall;
 
import java.util.LinkedHashMap;
import java.util.Map;
 
/**
 * Created by zhy on 15/12/14.
 */
public abstract class OkHttpRequestBuilder<T extends OkHttpRequestBuilder>
{
    protected String url;
    protected Object tag;
    protected Map<String, String> headers;
    protected Map<String, String> params;
    protected int id;
 
    public T id(int id)
    {
        this.id = id;
        return (T) this;
    }
 
    public T url(String url)
    {
        this.url = url;
        return (T) this;
    }
 
 
    public T tag(Object tag)
    {
        this.tag = tag;
        return (T) this;
    }
 
    public T headers(Map<String, String> headers)
    {
        this.headers = headers;
        return (T) this;
    }
 
    public T addHeader(String key, String val)
    {
        if (this.headers == null)
        {
            headers = new LinkedHashMap<>();
        }
        headers.put(key, val);
        return (T) this;
    }
 
    public abstract RequestCall build();
}