1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sourceforge.buildmonitor;
17
18 import java.util.Comparator;
19 import java.util.Date;
20
21
22
23
24
25
26 public class BuildReport
27 {
28
29
30
31
32
33
34
35
36 public static class NameComparator implements Comparator<BuildReport>
37 {
38
39 public int compare(BuildReport o1, BuildReport o2)
40 {
41 int returnedValue = 0;
42 if ((o1 == null) || (o2 == null))
43 {
44 throw new IllegalArgumentException("Cannot compare with null object");
45 }
46 String firstBuildReportName = o1.getName();
47 String secondBuildReportName = o2.getName();
48
49 if (firstBuildReportName == null)
50 {
51 if (secondBuildReportName == null)
52 {
53 returnedValue = 0;
54 }
55 else
56 {
57 returnedValue = -1;
58 }
59 }
60 else
61 {
62 if (secondBuildReportName == null)
63 {
64 returnedValue = 1;
65 }
66 else
67 {
68 returnedValue = firstBuildReportName.compareTo(secondBuildReportName);
69 }
70 }
71 return returnedValue;
72 }
73 }
74
75
76
77
78
79 public static class AgeComparator implements Comparator<BuildReport>
80 {
81
82 public int compare(BuildReport o1, BuildReport o2)
83 {
84 int returnedValue = 0;
85 if ((o1 == null) || (o2 == null))
86 {
87 throw new IllegalArgumentException("Cannot compare with null object");
88 }
89 Date firstBuildReportDate = o1.getDate();
90 Date secondBuildReportDate = o2.getDate();
91
92 if (firstBuildReportDate == null)
93 {
94 if (secondBuildReportDate == null)
95 {
96 returnedValue = 0;
97 }
98 else
99 {
100 returnedValue = -1;
101 }
102 }
103 else
104 {
105 if (secondBuildReportDate == null)
106 {
107 returnedValue = 1;
108 }
109 else
110 {
111 returnedValue = firstBuildReportDate.compareTo(secondBuildReportDate);
112 }
113 }
114 return returnedValue;
115 }
116
117 }
118
119
120
121
122
123
124
125
126
127
128 public enum Status {OK, FAILED};
129
130
131
132
133
134
135
136
137 private String id;
138
139
140
141
142 private String name;
143
144
145
146
147 private Status status;
148
149
150
151
152 private Date date;
153
154
155
156
157
158
159
160
161 public BuildReport()
162 {
163
164 }
165
166
167
168
169
170
171
172 public BuildReport(String theId, Date theDate, Status theStatus)
173 {
174 this.id = theId;
175 this.date = theDate;
176 this.status = theStatus;
177 }
178
179
180
181
182
183
184
185
186
187 public Date getDate()
188 {
189 return this.date;
190 }
191
192
193
194
195
196 public void setDate(Date theDateOfTheBuild)
197 {
198 this.date = theDateOfTheBuild;
199 }
200
201
202
203
204
205 public String getId()
206 {
207 return this.id;
208 }
209
210
211
212
213
214 public void setId(String theIdOfTheBuild)
215 {
216 this.id = theIdOfTheBuild;
217 }
218
219
220
221
222
223 public String getName()
224 {
225 return this.name;
226 }
227
228
229
230
231
232 public void setName(String theName)
233 {
234 this.name = theName;
235 }
236
237
238
239
240
241 public Status getStatus()
242 {
243 return this.status;
244 }
245
246
247
248
249
250 public void setStatus(Status theStatusOfTheBuild)
251 {
252 this.status = theStatusOfTheBuild;
253 }
254
255
256
257
258
259 public boolean hasFailed()
260 {
261 return Status.FAILED.equals(this.status);
262 }
263 }