• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk-gen / #226

20 Jun 2025 03:14PM UTC coverage: 35.609% (-0.2%) from 35.816%
#226

push

github

web-flow
feat: Shorten builder names in Java (box/box-codegen#742) (#334)

367 of 1570 new or added lines in 984 files covered. (23.38%)

674 existing lines in 370 files now uncovered.

16125 of 45284 relevant lines covered (35.61%)

0.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.49
/src/main/java/com/box/sdkgen/networking/network/NetworkSession.java
1
package com.box.sdkgen.networking.network;
2

3
import com.box.sdkgen.internal.logging.DataSanitizer;
4
import com.box.sdkgen.networking.baseurls.BaseUrls;
5
import com.box.sdkgen.networking.boxnetworkclient.BoxNetworkClient;
6
import com.box.sdkgen.networking.interceptors.Interceptor;
7
import com.box.sdkgen.networking.networkclient.NetworkClient;
8
import com.box.sdkgen.networking.retries.BoxRetryStrategy;
9
import com.box.sdkgen.networking.retries.RetryStrategy;
10
import java.util.ArrayList;
11
import java.util.HashMap;
12
import java.util.List;
13
import java.util.Map;
14
import java.util.stream.Collectors;
15
import java.util.stream.Stream;
16

17
public class NetworkSession {
18
  protected Map<String, String> additionalHeaders = new HashMap<>();
1✔
19

20
  protected BaseUrls baseUrls = new BaseUrls();
1✔
21

22
  protected List<Interceptor> interceptors = new ArrayList<>();
1✔
23

24
  protected NetworkClient networkClient;
25

26
  protected RetryStrategy retryStrategy;
27

28
  protected DataSanitizer dataSanitizer;
29

30
  public NetworkSession() {
1✔
31
    networkClient = new BoxNetworkClient();
1✔
32
    retryStrategy = new BoxRetryStrategy();
1✔
33
    dataSanitizer = new DataSanitizer();
1✔
34
  }
1✔
35

36
  protected NetworkSession(Builder builder) {
1✔
37
    this.additionalHeaders = builder.additionalHeaders;
1✔
38
    this.baseUrls = builder.baseUrls;
1✔
39
    this.networkClient = builder.networkClient;
1✔
40
    this.interceptors = builder.interceptors;
1✔
41
    this.retryStrategy = builder.retryStrategy;
1✔
42
    this.dataSanitizer = builder.dataSanitizer;
1✔
43
  }
1✔
44

45
  public NetworkSession withAdditionalHeaders() {
46
    return withAdditionalHeaders(new HashMap<>());
×
47
  }
48

49
  public NetworkSession withAdditionalHeaders(Map<String, String> additionalHeaders) {
50
    Map<String, String> newHeaders = new HashMap<>();
1✔
51
    newHeaders.putAll(this.additionalHeaders);
1✔
52
    newHeaders.putAll(additionalHeaders);
1✔
53
    return new NetworkSession.Builder()
1✔
54
        .additionalHeaders(newHeaders)
1✔
55
        .baseUrls(this.baseUrls)
1✔
56
        .interceptors(this.interceptors)
1✔
57
        .networkClient(this.networkClient)
1✔
58
        .retryStrategy(this.retryStrategy)
1✔
59
        .dataSanitizer(dataSanitizer)
1✔
60
        .build();
1✔
61
  }
62

63
  public NetworkSession withCustomBaseUrls(BaseUrls baseUrls) {
64
    return new Builder()
1✔
65
        .additionalHeaders(this.additionalHeaders)
1✔
66
        .baseUrls(baseUrls)
1✔
67
        .interceptors(this.interceptors)
1✔
68
        .networkClient(this.networkClient)
1✔
69
        .retryStrategy(this.retryStrategy)
1✔
70
        .dataSanitizer(dataSanitizer)
1✔
71
        .build();
1✔
72
  }
73

74
  public NetworkSession withInterceptors(List<Interceptor> interceptors) {
75
    List<Interceptor> newInterceptors =
1✔
76
        Stream.concat(this.interceptors.stream(), interceptors.stream())
1✔
77
            .collect(Collectors.toList());
1✔
78
    return new Builder()
1✔
79
        .additionalHeaders(this.additionalHeaders)
1✔
80
        .baseUrls(this.baseUrls)
1✔
81
        .interceptors(newInterceptors)
1✔
82
        .networkClient(this.networkClient)
1✔
83
        .retryStrategy(this.retryStrategy)
1✔
84
        .dataSanitizer(dataSanitizer)
1✔
85
        .build();
1✔
86
  }
87

88
  public NetworkSession withNetworkClient(NetworkClient networkClient) {
NEW
89
    return new Builder()
×
90
        .additionalHeaders(this.additionalHeaders)
×
91
        .baseUrls(this.baseUrls)
×
92
        .interceptors(this.interceptors)
×
93
        .networkClient(networkClient)
×
94
        .retryStrategy(this.retryStrategy)
×
95
        .dataSanitizer(dataSanitizer)
×
96
        .build();
×
97
  }
98

99
  public NetworkSession withRetryStrategy(RetryStrategy retryStrategy) {
NEW
100
    return new Builder()
×
101
        .additionalHeaders(this.additionalHeaders)
×
102
        .baseUrls(this.baseUrls)
×
103
        .interceptors(this.interceptors)
×
104
        .networkClient(this.networkClient)
×
105
        .retryStrategy(retryStrategy)
×
106
        .dataSanitizer(dataSanitizer)
×
107
        .build();
×
108
  }
109

110
  public NetworkSession withDataSanitizer(DataSanitizer dataSanitizer) {
NEW
111
    return new Builder()
×
112
        .additionalHeaders(this.additionalHeaders)
×
113
        .baseUrls(this.baseUrls)
×
114
        .interceptors(this.interceptors)
×
115
        .networkClient(this.networkClient)
×
116
        .retryStrategy(this.retryStrategy)
×
117
        .dataSanitizer(dataSanitizer)
×
118
        .build();
×
119
  }
120

121
  public Map<String, String> getAdditionalHeaders() {
122
    return additionalHeaders;
1✔
123
  }
124

125
  public BaseUrls getBaseUrls() {
126
    return baseUrls;
1✔
127
  }
128

129
  public NetworkClient getNetworkClient() {
130
    return networkClient;
1✔
131
  }
132

133
  public List<Interceptor> getInterceptors() {
134
    return interceptors;
1✔
135
  }
136

137
  public RetryStrategy getRetryStrategy() {
138
    return retryStrategy;
1✔
139
  }
140

141
  public DataSanitizer getDataSanitizer() {
142
    return dataSanitizer;
1✔
143
  }
144

145
  public static class Builder {
146

147
    protected Map<String, String> additionalHeaders = new HashMap<>();
1✔
148

149
    protected BaseUrls baseUrls = new BaseUrls();
1✔
150

151
    protected NetworkClient networkClient;
152

153
    protected List<Interceptor> interceptors = new ArrayList<>();
1✔
154

155
    protected RetryStrategy retryStrategy;
156

157
    protected DataSanitizer dataSanitizer;
158

159
    public Builder() {
1✔
160
      networkClient = new BoxNetworkClient();
1✔
161
      retryStrategy = new BoxRetryStrategy();
1✔
162
      dataSanitizer = new DataSanitizer();
1✔
163
    }
1✔
164

165
    public Builder additionalHeaders(Map<String, String> additionalHeaders) {
166
      this.additionalHeaders = additionalHeaders;
1✔
167
      return this;
1✔
168
    }
169

170
    public Builder baseUrls(BaseUrls baseUrls) {
171
      this.baseUrls = baseUrls;
1✔
172
      return this;
1✔
173
    }
174

175
    public Builder networkClient(NetworkClient networkClient) {
176
      this.networkClient = networkClient;
1✔
177
      return this;
1✔
178
    }
179

180
    public Builder interceptors(List<Interceptor> interceptors) {
181
      this.interceptors = interceptors;
1✔
182
      return this;
1✔
183
    }
184

185
    public Builder retryStrategy(RetryStrategy retryStrategy) {
186
      this.retryStrategy = retryStrategy;
1✔
187
      return this;
1✔
188
    }
189

190
    public Builder dataSanitizer(DataSanitizer dataSanitizer) {
191
      this.dataSanitizer = dataSanitizer;
1✔
192
      return this;
1✔
193
    }
194

195
    public NetworkSession build() {
196
      return new NetworkSession(this);
1✔
197
    }
198
  }
199
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc