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

Henri Biestro edited comment on JEXL-428 at 9/25/24 5:49 AM:
-------------------------------------------------------------

The problem with Comparable interface is that its generic nature implies the 
signature is compareTo(Object) which does not help disambiguate the call. The 
workaround is to implement your own 'public int compare(MyClass lhs, String 
rhs)' - or any signature you need to disambiguate - in your own derived 
arithmetic.

Commit 
[2d2300e|https://github.com/apache/commons-jexl/commit/2d2300e0fea55e1da432d3ef1b04ba49afc5b025]


was (Author: henrib):
Commit 
[2d2300e|https://github.com/apache/commons-jexl/commit/2d2300e0fea55e1da432d3ef1b04ba49afc5b025]

> 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
>    Affects Versions: 3.4.0
>            Reporter: Xu Pengcheng
>            Assignee: Henri Biestro
>            Priority: Major
>             Fix For: 3.4.1
>
>
> [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)

Reply via email to