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.util.Comparator;
26
27 import net.sf.statcvs.model.VersionedFile;
28
29 /**
30 * Compares two files according to their lines of code
31 *
32 * @author Richard Cyganiak <rcyg@gmx.de>
33 * @version $Id: FilesLocComparator.java,v 1.3 2008/04/02 11:22:15 benoitx Exp $
34 */
35 public class FilesLocComparator implements Comparator {
36
37 /**
38 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
39 */
40 public int compare(final Object o1, final Object o2) {
41 final VersionedFile file1 = (VersionedFile) o1;
42 final VersionedFile file2 = (VersionedFile) o2;
43 if (file1.getCurrentLinesOfCode() < file2.getCurrentLinesOfCode()) {
44 return 1;
45 } else if (file1.getCurrentLinesOfCode() == file2.getCurrentLinesOfCode()) {
46 return 0;
47 } else {
48 return -1;
49 }
50 }
51 }