You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (Jira)" <ji...@apache.org> on 2024/09/06 10:35:00 UTC

[jira] [Commented] (JEXL-428) Make Comparable object high priority while comparing

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

Henri Biestro commented on JEXL-428:
------------------------------------

The difficulty might be in respecting the expectation :{code}compare(x, y) == -compare(y, x){code}

The lengthy workaround would be to implement the operator methods in the JexlArithmetic with the intended signature (public boolean lessThan(XuClass xu, String right); public boolean greaterThan(String right, XuClass xu); etc.).
As an improvement, it could be possible to expose a compare operator (JexlOperator.COMPARE) to only have to implement 2 methods.

Wdyt ?

> Make Comparable object high priority while comparing
> ----------------------------------------------------
>
>                 Key: JEXL-428
>                 URL: https://issues.apache.org/jira/browse/JEXL-428
>             Project: Commons JEXL
>          Issue Type: Improvement
>            Reporter: Xu Pengcheng
>            Priority: Major
>
> [https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java#L787]
>  
> I defined a Class with implemented Comparable interface, when compare it with a string object, engine does not call the compareTo method but compares by string value.
>  
> At JexlArithmetic.java L787, if one of the left/right value is string type, then compares by string value, I think if the left value is Comparable and not String type, using left object's compareTo method first makes more sense.
> Thanks!
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)