dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17292
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6823: Fixed bug with ValidationResultComparator
------------------------------------------------------------
revno: 6823
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-05-01 15:49:47 +0200
message:
Fixed bug with ValidationResultComparator
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/comparator/ValidationResultComparator.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/comparator/ValidationResultComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/comparator/ValidationResultComparator.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/comparator/ValidationResultComparator.java 2012-05-01 13:49:47 +0000
@@ -32,26 +32,28 @@
import org.hisp.dhis.validation.ValidationResult;
/**
+ * Comparator sorting on the result period.
+ *
* @author Lars Helge Overland
- * @version $Id$
*/
public class ValidationResultComparator
implements Comparator<ValidationResult>
{
public int compare( ValidationResult result1, ValidationResult result2 )
{
- if ( result1.getPeriod() == null )
+ if ( result1.getPeriod() == null && result2.getPeriod() == null )
+ {
+ return 0;
+ }
+ else if ( result1.getPeriod() == null )
+ {
+ return 1;
+ }
+ else if ( result2.getPeriod() == null )
{
return -1;
}
- if ( result2.getPeriod() == null )
- {
- return 1;
- }
-
- boolean after = result1.getPeriod().getStartDate().after( result2.getPeriod().getStartDate() );
-
- return after ? 1 : -1;
+ return result1.getPeriod().getStartDate().compareTo( result2.getPeriod().getStartDate() );
}
}