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