← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21583: minor simplification in OrderParams

 

------------------------------------------------------------
revno: 21583
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-01-05 16:05:54 +0700
message:
  minor simplification in OrderParams
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderParams.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	2016-01-05 08:30:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.java	2016-01-05 09:05:54 +0000
@@ -148,6 +148,23 @@
         return new Order( property, false ).ignoreCase();
     }
 
+    public static Order from( String direction, Property property )
+    {
+        switch ( direction )
+        {
+            case "asc":
+                return Order.asc( property );
+            case "iasc":
+                return Order.iasc( property );
+            case "desc":
+                return Order.desc( property );
+            case "idesc":
+                return Order.idesc( property );
+            default:
+                return Order.asc( property );
+        }
+    }
+
     @Override
     public int hashCode()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderParams.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderParams.java	2016-01-05 08:30:32 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderParams.java	2016-01-05 09:05:54 +0000
@@ -80,28 +80,7 @@
                 continue;
             }
 
-            Order order;
-
-            switch ( direction )
-            {
-                case "asc":
-                    order = Order.asc( property );
-                    break;
-                case "iasc":
-                    order = Order.iasc( property );
-                    break;
-                case "desc":
-                    order = Order.desc( property );
-                    break;
-                case "idesc":
-                    order = Order.idesc( property );
-                    break;
-                default:
-                    order = Order.asc( property );
-                    break;
-            }
-
-            orders.put( propertyName, order );
+            orders.put( propertyName, Order.from( direction, property ) );
         }
 
         return new ArrayList<>( orders.values() );