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 public long getNumBytesRead() {
70 return numBytesRead;
71 }
72
73
74 public long getNumWholeCommit() {
75 return numWholeCommit;
76 }
77
78
79 public long getNumWholeTree() {
80 return numWholeTree;
81 }
82
83
84 public long getNumWholeBlob() {
85 return numWholeBlob;
86 }
87
88
89 public long getNumWholeTag() {
90 return numWholeTag;
91 }
92
93
94 public long getNumOfsDelta() {
95 return numOfsDelta;
96 }
97
98
99 public long getNumRefDelta() {
100 return numRefDelta;
101 }
102
103
104 public long getNumDeltaCommit() {
105 return numDeltaCommit;
106 }
107
108
109 public long getNumDeltaTree() {
110 return numDeltaTree;
111 }
112
113
114 public long getNumDeltaBlob() {
115 return numDeltaBlob;
116 }
117
118
119 public long getNumDeltaTag() {
120 return numDeltaTag;
121 }
122
123
124 public static class Builder {
125 private long numBytesRead;
126
127 private long numWholeCommit;
128 private long numWholeTree;
129 private long numWholeBlob;
130 private long numWholeTag;
131 private long numOfsDelta;
132 private long numRefDelta;
133
134 private long numDeltaCommit;
135 private long numDeltaTree;
136 private long numDeltaBlob;
137 private long numDeltaTag;
138
139
140
141
142
143 public Builder setNumBytesRead(long numBytesRead) {
144 this.numBytesRead = numBytesRead;
145 return this;
146 }
147
148
149
150
151
152
153
154 public Builder addWholeObject(int type) {
155 switch (type) {
156 case Constants.OBJ_COMMIT:
157 numWholeCommit++;
158 break;
159 case Constants.OBJ_TREE:
160 numWholeTree++;
161 break;
162 case Constants.OBJ_BLOB:
163 numWholeBlob++;
164 break;
165 case Constants.OBJ_TAG:
166 numWholeTag++;
167 break;
168 default:
169 throw new IllegalArgumentException(
170 type + " cannot be a whole object");
171 }
172 return this;
173 }
174
175
176 public Builder addOffsetDelta() {
177 numOfsDelta++;
178 return this;
179 }
180
181
182 public Builder addRefDelta() {
183 numRefDelta++;
184 return this;
185 }
186
187
188
189
190
191
192
193 public Builder addDeltaObject(int type) {
194 switch (type) {
195 case Constants.OBJ_COMMIT:
196 numDeltaCommit++;
197 break;
198 case Constants.OBJ_TREE:
199 numDeltaTree++;
200 break;
201 case Constants.OBJ_BLOB:
202 numDeltaBlob++;
203 break;
204 case Constants.OBJ_TAG:
205 numDeltaTag++;
206 break;
207 default:
208 throw new IllegalArgumentException(
209 "delta should be a delta to a whole object. " +
210 type + " cannot be a whole object");
211 }
212 return this;
213 }
214
215 ReceivedPackStatistics build() {
216 ReceivedPackStatistics s = new ReceivedPackStatistics();
217 s.numBytesRead = numBytesRead;
218 s.numWholeCommit = numWholeCommit;
219 s.numWholeTree = numWholeTree;
220 s.numWholeBlob = numWholeBlob;
221 s.numWholeTag = numWholeTag;
222 s.numOfsDelta = numOfsDelta;
223 s.numRefDelta = numRefDelta;
224 s.numDeltaCommit = numDeltaCommit;
225 s.numDeltaTree = numDeltaTree;
226 s.numDeltaBlob = numDeltaBlob;
227 s.numDeltaTag = numDeltaTag;
228 return s;
229 }
230 }
231 }