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 package org.eclipse.jgit.transport;
44
45 import static java.util.Objects.requireNonNull;
46
47 import java.util.ArrayList;
48 import java.util.Collections;
49 import java.util.HashSet;
50 import java.util.List;
51 import java.util.Set;
52
53 import org.eclipse.jgit.annotations.NonNull;
54 import org.eclipse.jgit.annotations.Nullable;
55 import org.eclipse.jgit.lib.ObjectId;
56
57
58
59
60
61
62
63
64
65 public final class FetchV2Request extends FetchRequest {
66 private final List<ObjectId> peerHas;
67
68 private final List<String> wantedRefs;
69
70 private final boolean doneReceived;
71
72 @NonNull
73 private final List<String> serverOptions;
74
75 FetchV2Request(@NonNull List<ObjectId> peerHas,
76 @NonNull List<String> wantedRefs,
77 @NonNull Set<ObjectId> wantIds,
78 @NonNull Set<ObjectId> clientShallowCommits, int deepenSince,
79 @NonNull List<String> deepenNotRefs, int depth,
80 long filterBlobLimit,
81 boolean doneReceived, @NonNull Set<String> clientCapabilities,
82 @Nullable String agent, @NonNull List<String> serverOptions) {
83 super(wantIds, depth, clientShallowCommits, filterBlobLimit,
84 clientCapabilities, deepenSince, deepenNotRefs, agent);
85 this.peerHas = requireNonNull(peerHas);
86 this.wantedRefs = requireNonNull(wantedRefs);
87 this.doneReceived = doneReceived;
88 this.serverOptions = requireNonNull(serverOptions);
89 }
90
91
92
93
94 @NonNull
95 List<ObjectId> getPeerHas() {
96 return peerHas;
97 }
98
99
100
101
102 @NonNull
103 List<String> getWantedRefs() {
104 return wantedRefs;
105 }
106
107
108
109
110 boolean wasDoneReceived() {
111 return doneReceived;
112 }
113
114
115
116
117
118
119
120
121
122 @NonNull
123 public List<String> getServerOptions() {
124 return serverOptions;
125 }
126
127
128 static Builder builder() {
129 return new Builder();
130 }
131
132
133 static final class Builder {
134 final List<ObjectId> peerHas = new ArrayList<>();
135
136 final List<String> wantedRefs = new ArrayList<>();
137
138 final Set<ObjectId> wantIds = new HashSet<>();
139
140 final Set<ObjectId> clientShallowCommits = new HashSet<>();
141
142 final List<String> deepenNotRefs = new ArrayList<>();
143
144 final Set<String> clientCapabilities = new HashSet<>();
145
146 int depth;
147
148 int deepenSince;
149
150 long filterBlobLimit = -1;
151
152 boolean doneReceived;
153
154 @Nullable
155 String agent;
156
157 final List<String> serverOptions = new ArrayList<>();
158
159 private Builder() {
160 }
161
162
163
164
165
166
167 Builder addPeerHas(ObjectId objectId) {
168 peerHas.add(objectId);
169 return this;
170 }
171
172
173
174
175
176
177
178
179 Builder addWantedRef(String refName) {
180 wantedRefs.add(refName);
181 return this;
182 }
183
184
185
186
187
188
189 Builder addClientCapability(String clientCapability) {
190 clientCapabilities.add(clientCapability);
191 return this;
192 }
193
194
195
196
197
198
199 Builder addWantId(ObjectId wantId) {
200 wantIds.add(wantId);
201 return this;
202 }
203
204
205
206
207
208
209 Builder addClientShallowCommit(ObjectId shallowOid) {
210 clientShallowCommits.add(shallowOid);
211 return this;
212 }
213
214
215
216
217
218
219 Builder setDepth(int d) {
220 depth = d;
221 return this;
222 }
223
224
225
226
227
228 int getDepth() {
229 return depth;
230 }
231
232
233
234
235
236 boolean hasDeepenNotRefs() {
237 return !deepenNotRefs.isEmpty();
238 }
239
240
241
242
243
244
245 Builder addDeepenNotRef(String deepenNotRef) {
246 deepenNotRefs.add(deepenNotRef);
247 return this;
248 }
249
250
251
252
253
254
255 Builder setDeepenSince(int value) {
256 deepenSince = value;
257 return this;
258 }
259
260
261
262
263
264 int getDeepenSince() {
265 return deepenSince;
266 }
267
268
269
270
271
272
273 Builder setFilterBlobLimit(long filterBlobLim) {
274 filterBlobLimit = filterBlobLim;
275 return this;
276 }
277
278
279
280
281
282
283 Builder setDoneReceived() {
284 doneReceived = true;
285 return this;
286 }
287
288
289
290
291
292
293
294
295
296
297 Builder setAgent(@Nullable String agentValue) {
298 agent = agentValue;
299 return this;
300 }
301
302
303
304
305
306
307
308
309
310
311
312 Builder addServerOption(@NonNull String value) {
313 serverOptions.add(value);
314 return this;
315 }
316
317
318
319
320 FetchV2Request build() {
321 return new FetchV2Request(peerHas, wantedRefs, wantIds,
322 clientShallowCommits, deepenSince, deepenNotRefs,
323 depth, filterBlobLimit, doneReceived, clientCapabilities,
324 agent, Collections.unmodifiableList(serverOptions));
325 }
326 }
327 }