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
44 package org.eclipse.jgit.transport;
45
46 import org.eclipse.jgit.lib.Constants;
47
48
49
50
51
52
53 public class ReceivedPackStatistics {
54 private long numBytesRead;
55
56 private long numWholeCommit;
57 private long numWholeTree;
58 private long numWholeBlob;
59 private long numWholeTag;
60 private long numOfsDelta;
61 private long numRefDelta;
62
63 private long numDeltaCommit;
64 private long numDeltaTree;
65 private long numDeltaBlob;
66 private long numDeltaTag;
67
68
69
70
71
72
73 public long getNumBytesRead() {
74 return numBytesRead;
75 }
76
77
78
79
80
81
82 public long getNumWholeCommit() {
83 return numWholeCommit;
84 }
85
86
87
88
89
90
91 public long getNumWholeTree() {
92 return numWholeTree;
93 }
94
95
96
97
98
99
100 public long getNumWholeBlob() {
101 return numWholeBlob;
102 }
103
104
105
106
107
108
109 public long getNumWholeTag() {
110 return numWholeTag;
111 }
112
113
114
115
116
117
118 public long getNumOfsDelta() {
119 return numOfsDelta;
120 }
121
122
123
124
125
126
127 public long getNumRefDelta() {
128 return numRefDelta;
129 }
130
131
132
133
134
135
136 public long getNumDeltaCommit() {
137 return numDeltaCommit;
138 }
139
140
141
142
143
144
145 public long getNumDeltaTree() {
146 return numDeltaTree;
147 }
148
149
150
151
152
153
154 public long getNumDeltaBlob() {
155 return numDeltaBlob;
156 }
157
158
159
160
161
162
163 public long getNumDeltaTag() {
164 return numDeltaTag;
165 }
166
167
168 public static class Builder {
169 private long numBytesRead;
170
171 private long numWholeCommit;
172 private long numWholeTree;
173 private long numWholeBlob;
174 private long numWholeTag;
175 private long numOfsDelta;
176 private long numRefDelta;
177
178 private long numDeltaCommit;
179 private long numDeltaTree;
180 private long numDeltaBlob;
181 private long numDeltaTag;
182
183
184
185
186
187 public Builder setNumBytesRead(long numBytesRead) {
188 this.numBytesRead = numBytesRead;
189 return this;
190 }
191
192
193
194
195
196
197
198 public Builder addWholeObject(int type) {
199 switch (type) {
200 case Constants.OBJ_COMMIT:
201 numWholeCommit++;
202 break;
203 case Constants.OBJ_TREE:
204 numWholeTree++;
205 break;
206 case Constants.OBJ_BLOB:
207 numWholeBlob++;
208 break;
209 case Constants.OBJ_TAG:
210 numWholeTag++;
211 break;
212 default:
213 throw new IllegalArgumentException(
214 type + " cannot be a whole object");
215 }
216 return this;
217 }
218
219
220 public Builder addOffsetDelta() {
221 numOfsDelta++;
222 return this;
223 }
224
225
226 public Builder addRefDelta() {
227 numRefDelta++;
228 return this;
229 }
230
231
232
233
234
235
236
237 public Builder addDeltaObject(int type) {
238 switch (type) {
239 case Constants.OBJ_COMMIT:
240 numDeltaCommit++;
241 break;
242 case Constants.OBJ_TREE:
243 numDeltaTree++;
244 break;
245 case Constants.OBJ_BLOB:
246 numDeltaBlob++;
247 break;
248 case Constants.OBJ_TAG:
249 numDeltaTag++;
250 break;
251 default:
252 throw new IllegalArgumentException(
253 "delta should be a delta to a whole object. " +
254 type + " cannot be a whole object");
255 }
256 return this;
257 }
258
259 ReceivedPackStatistics build() {
260 ReceivedPackStatistics s = new ReceivedPackStatistics();
261 s.numBytesRead = numBytesRead;
262 s.numWholeCommit = numWholeCommit;
263 s.numWholeTree = numWholeTree;
264 s.numWholeBlob = numWholeBlob;
265 s.numWholeTag = numWholeTag;
266 s.numOfsDelta = numOfsDelta;
267 s.numRefDelta = numRefDelta;
268 s.numDeltaCommit = numDeltaCommit;
269 s.numDeltaTree = numDeltaTree;
270 s.numDeltaBlob = numDeltaBlob;
271 s.numDeltaTag = numDeltaTag;
272 return s;
273 }
274 }
275 }