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