1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.transport;
11
12 import static java.util.Objects.requireNonNull;
13
14 import java.util.Collection;
15 import java.util.Collections;
16 import java.util.HashSet;
17 import java.util.Set;
18
19 import org.eclipse.jgit.annotations.NonNull;
20 import org.eclipse.jgit.annotations.Nullable;
21 import org.eclipse.jgit.lib.ObjectId;
22
23
24
25
26 final class FetchV0Request extends FetchRequest {
27
28 FetchV0Request(@NonNull Set<ObjectId> wantIds, int depth,
29 @NonNull Set<ObjectId> clientShallowCommits,
30 @NonNull FilterSpec filterSpec,
31 @NonNull Set<String> clientCapabilities, @Nullable String agent) {
32 super(wantIds, depth, clientShallowCommits, filterSpec,
33 clientCapabilities, 0, Collections.emptyList(), agent);
34 }
35
36 static final class Builder {
37
38 int depth;
39
40 final Set<ObjectId> wantIds = new HashSet<>();
41
42 final Set<ObjectId> clientShallowCommits = new HashSet<>();
43
44 FilterSpec filterSpec = FilterSpec.NO_FILTER;
45
46 final Set<String> clientCaps = new HashSet<>();
47
48 String agent;
49
50
51
52
53
54
55 Builder addWantId(ObjectId objectId) {
56 wantIds.add(objectId);
57 return this;
58 }
59
60
61
62
63
64
65 Builder setDepth(int d) {
66 depth = d;
67 return this;
68 }
69
70
71
72
73
74
75 Builder addClientShallowCommit(ObjectId shallowOid) {
76 clientShallowCommits.add(shallowOid);
77 return this;
78 }
79
80
81
82
83
84
85
86 Builder addClientCapabilities(Collection<String> clientCapabilities) {
87 clientCaps.addAll(clientCapabilities);
88 return this;
89 }
90
91
92
93
94
95
96 Builder setAgent(String clientAgent) {
97 agent = clientAgent;
98 return this;
99 }
100
101
102
103
104
105
106 Builder setFilterSpec(@NonNull FilterSpec filter) {
107 filterSpec = requireNonNull(filter);
108 return this;
109 }
110
111 FetchV0Request build() {
112 return new FetchV0Request(wantIds, depth, clientShallowCommits,
113 filterSpec, clientCaps, agent);
114 }
115
116 }
117 }