1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.statcvs.reports;
24
25 import java.io.Serializable;
26 import java.util.Comparator;
27
28 import net.sf.statcvs.model.VersionedFile;
29
30 /**
31 * Compares two files according to their lines of code
32 *
33 * @author Richard Cyganiak <rcyg@gmx.de>
34 * @version $Id: FilesLocComparator.java,v 1.4 2009/08/20 17:44:05 benoitx Exp $
35 */
36 public class FilesLocComparator implements Comparator, Serializable {
37
38 /**
39 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
40 */
41 public int compare(final Object o1, final Object o2) {
42 final VersionedFile file1 = (VersionedFile) o1;
43 final VersionedFile file2 = (VersionedFile) o2;
44 if (file1.getCurrentLinesOfCode() < file2.getCurrentLinesOfCode()) {
45 return 1;
46 } else if (file1.getCurrentLinesOfCode() == file2.getCurrentLinesOfCode()) {
47 return 0;
48 } else {
49 return -1;
50 }
51 }
52 }