1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.transport;
12
13 import org.eclipse.jgit.lib.Constants;
14
15
16
17
18
19
20 public class ReceivedPackStatistics {
21 private long numBytesRead;
22
23 private long numWholeCommit;
24 private long numWholeTree;
25 private long numWholeBlob;
26 private long numWholeTag;
27 private long numOfsDelta;
28 private long numRefDelta;
29
30 private long numDeltaCommit;
31 private long numDeltaTree;
32 private long numDeltaBlob;
33 private long numDeltaTag;
34
35
36
37
38
39
40 public long getNumBytesRead() {
41 return numBytesRead;
42 }
43
44
45
46
47
48
49 public long getNumWholeCommit() {
50 return numWholeCommit;
51 }
52
53
54
55
56
57
58 public long getNumWholeTree() {
59 return numWholeTree;
60 }
61
62
63
64
65
66
67 public long getNumWholeBlob() {
68 return numWholeBlob;
69 }
70
71
72
73
74
75
76 public long getNumWholeTag() {
77 return numWholeTag;
78 }
79
80
81
82
83
84
85 public long getNumOfsDelta() {
86 return numOfsDelta;
87 }
88
89
90
91
92
93
94 public long getNumRefDelta() {
95 return numRefDelta;
96 }
97
98
99
100
101
102
103 public long getNumDeltaCommit() {
104 return numDeltaCommit;
105 }
106
107
108
109
110
111
112 public long getNumDeltaTree() {
113 return numDeltaTree;
114 }
115
116
117
118
119
120
121 public long getNumDeltaBlob() {
122 return numDeltaBlob;
123 }
124
125
126
127
128
129
130 public long getNumDeltaTag() {
131 return numDeltaTag;
132 }
133
134
135 public static class Builder {
136 private long numBytesRead;
137
138 private long numWholeCommit;
139 private long numWholeTree;
140 private long numWholeBlob;
141 private long numWholeTag;
142 private long numOfsDelta;
143 private long numRefDelta;
144
145 private long numDeltaCommit;
146 private long numDeltaTree;
147 private long numDeltaBlob;
148 private long numDeltaTag;
149
150
151
152
153
154 public Builder setNumBytesRead(long numBytesRead) {
155 this.numBytesRead = numBytesRead;
156 return this;
157 }
158
159
160
161
162
163
164
165 public Builder addWholeObject(int type) {
166 switch (type) {
167 case Constants.OBJ_COMMIT:
168 numWholeCommit++;
169 break;
170 case Constants.OBJ_TREE:
171 numWholeTree++;
172 break;
173 case Constants.OBJ_BLOB:
174 numWholeBlob++;
175 break;
176 case Constants.OBJ_TAG:
177 numWholeTag++;
178 break;
179 default:
180 throw new IllegalArgumentException(
181 type + " cannot be a whole object");
182 }
183 return this;
184 }
185
186
187 public Builder addOffsetDelta() {
188 numOfsDelta++;
189 return this;
190 }
191
192
193 public Builder addRefDelta() {
194 numRefDelta++;
195 return this;
196 }
197
198
199
200
201
202
203
204 public Builder addDeltaObject(int type) {
205 switch (type) {
206 case Constants.OBJ_COMMIT:
207 numDeltaCommit++;
208 break;
209 case Constants.OBJ_TREE:
210 numDeltaTree++;
211 break;
212 case Constants.OBJ_BLOB:
213 numDeltaBlob++;
214 break;
215 case Constants.OBJ_TAG:
216 numDeltaTag++;
217 break;
218 default:
219 throw new IllegalArgumentException(
220 "delta should be a delta to a whole object. " +
221 type + " cannot be a whole object");
222 }
223 return this;
224 }
225
226 ReceivedPackStatistics build() {
227 ReceivedPackStatistics s = new ReceivedPackStatistics();
228 s.numBytesRead = numBytesRead;
229 s.numWholeCommit = numWholeCommit;
230 s.numWholeTree = numWholeTree;
231 s.numWholeBlob = numWholeBlob;
232 s.numWholeTag = numWholeTag;
233 s.numOfsDelta = numOfsDelta;
234 s.numRefDelta = numRefDelta;
235 s.numDeltaCommit = numDeltaCommit;
236 s.numDeltaTree = numDeltaTree;
237 s.numDeltaBlob = numDeltaBlob;
238 s.numDeltaTag = numDeltaTag;
239 return s;
240 }
241 }
242 }