groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8218) Allow to specify reverse order for @Sortable
Date Wed, 05 Jul 2017 05:05:02 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-8218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16074254#comment-16074254
] 

ASF GitHub Bot commented on GROOVY-8218:
----------------------------------------

Github user jwagenleitner commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/558#discussion_r125552693
  
    --- Diff: src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java ---
    @@ -219,10 +219,38 @@ public static ClosureExpression closureX(Statement code) {
             return result;
         }
     
    +    /**
    +     * Build a binary expression that compares two values
    +     * @param lhv expression for the value to compare from
    +     * @param rhv expression for the value value to compare to
    +     * @return the expression comparing two values
    +     */
         public static BinaryExpression cmpX(Expression lhv, Expression rhv) {
             return new BinaryExpression(lhv, CMP, rhv);
         }
     
    +    /**
    +     * Build a binary expression that compares two values
    +     * @param lhv expression for the value to compare from
    +     * @param rhv expression for the value value to compare to
    +     * @param reversed whether to use natural ordering or reversed natural ordering
    +     * @return the expression comparing two values
    +     */
    +    public static BinaryExpression cmpX(Expression lhv, Expression rhv, boolean reversed)
{
    +        return (reversed) ? cmpXReversed(lhv, rhv) : cmpX(lhv, rhv);
    --- End diff --
    
    What about `return (reversed) ? cmpX(rhv, lhv) : cmpX(lhv, rhv);`?  Could eliminate the
need for the new `cmpXReversed` method.


> Allow to specify reverse order for @Sortable
> --------------------------------------------
>
>                 Key: GROOVY-8218
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8218
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul-Julien Vauthier
>            Priority: Minor
>
> When using the Sortable annotation it is not possible to use reverse order. 
> For a leaderboard, you may want to sort its entries by points. 
> {code}
> @Sortable(reversed = true)
> class LeaderBoardEntry {
>   int points
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message