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