1 | /* | |
2 | * This file is part of the programmer editor demo | |
3 | * Copyright (C) 2001-2005 Stephen Ostermiller | |
4 | * http://ostermiller.org/contact.pl?regarding=Syntax+Highlighting | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * See COPYING.TXT for details. | |
17 | */ | |
18 | package com.jsql.view.swing.sql.lexer; | |
19 | ||
20 | import java.util.Comparator; | |
21 | ||
22 | /** | |
23 | * A comparator appropriate for use with Collections of | |
24 | * DocPositions. | |
25 | */ | |
26 | class DocPositionComparator implements Comparator<DocPosition> { | |
27 | | |
28 | public static final DocPositionComparator instance = new DocPositionComparator(); | |
29 | | |
30 | private DocPositionComparator() { | |
31 | // Util class | |
32 | } | |
33 | | |
34 | /** | |
35 | * Does this Comparator equal another? | |
36 | * Since all DocPositionComparators are the same, they | |
37 | * are all equal. | |
38 | * | |
39 | * @return true for DocPositionComparators, false otherwise. | |
40 | */ | |
41 | @Override | |
42 | public boolean equals(Object obj) { | |
43 |
2
1. equals : negated conditional → NO_COVERAGE 2. equals : replaced boolean return with true for com/jsql/view/swing/sql/lexer/DocPositionComparator::equals → NO_COVERAGE |
return this == obj; |
44 | } | |
45 | ||
46 | /** | |
47 | * Compare two DocPositions | |
48 | * | |
49 | * @param o1 first DocPosition | |
50 | * @param o2 second DocPosition | |
51 | * @return negative if first < second, 0 if equal, positive if first > second | |
52 | */ | |
53 | @Override | |
54 | public int compare(DocPosition o1, DocPosition o2) { | |
55 |
2
1. compare : replaced int return with 0 for com/jsql/view/swing/sql/lexer/DocPositionComparator::compare → NO_COVERAGE 2. compare : Replaced integer subtraction with addition → NO_COVERAGE |
return o1.getPosition() - o2.getPosition(); |
56 | } | |
57 | } | |
58 | ||
Mutations | ||
43 |
1.1 2.2 |
|
55 |
1.1 2.2 |