dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41222
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20989: support in-memory sorting of boolean and enums
------------------------------------------------------------
revno: 20989
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-09 14:46:37 +0700
message:
support in-memory sorting of boolean and enums
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.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-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.java 2015-11-09 07:41:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.java 2015-11-09 07:46:37 +0000
@@ -82,6 +82,10 @@
{
return ascending ? ((String) o1).compareTo( (String) o2 ) : ((String) o2).compareTo( (String) o1 );
}
+ if ( Boolean.class.isInstance( o1 ) && Boolean.class.isInstance( o2 ) )
+ {
+ return ascending ? ((Boolean) o1).compareTo( (Boolean) o2 ) : ((Boolean) o2).compareTo( (Boolean) o1 );
+ }
else if ( Integer.class.isInstance( o1 ) && Integer.class.isInstance( o2 ) )
{
return ascending ? ((Integer) o1).compareTo( (Integer) o2 ) : ((Integer) o2).compareTo( (Integer) o1 );
@@ -98,6 +102,10 @@
{
return ascending ? ((Date) o1).compareTo( (Date) o2 ) : ((Date) o2).compareTo( (Date) o1 );
}
+ else if ( Enum.class.isInstance( o1 ) && Enum.class.isInstance( o2 ) )
+ {
+ return ascending ? String.valueOf( o1 ).compareTo( String.valueOf( o2 ) ) : String.valueOf( o2 ).compareTo( String.valueOf( o1 ) );
+ }
return 0;
}