private void buildOrderBy ( final StringBuilder orderByBuilder , final Map < String , SortDirection > sorts ) { boolean isFirst = true ; String querySortDirection ; for ( final Map . Entry < String , SortDirection > sort : sorts . entrySet ( ) ) { if ( isFirst ) { orderByBuilder . append ( " ORDER BY " ) ; isFirst = false ; } else { orderByBuilder . append ( ", " ) ; } if ( sort . getValue ( ) . equals ( SortDirection . ASCENDING ) ) { querySortDirection = "ASC" ; } else { querySortDirection = "DESC" ; } orderByBuilder . append ( sort . getKey ( ) ) . append ( " " ) . append ( querySortDirection ) ; } }
Builds ORDER BY part with the specified order by build and sorts .