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

Arturo Bernal commented on LANG-1520:
-------------------------------------

Hi [~ggregory]

 

The method equals are Deprecated. Do we implement it or do we close the Jira?

 

[https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/ObjectUtils.java#L627]

 

Regards

 

> ObjectUtils.equals can use comparable if that's present.
> --------------------------------------------------------
>
>                 Key: LANG-1520
>                 URL: https://issues.apache.org/jira/browse/LANG-1520
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.9
>            Reporter: Sahil Soni
>            Priority: Minor
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> {{ObjectUtils.equals(Object, Object)}} is marked for deprecation in favour of 
> {{java.util.Objects.equals(Object, Object)}}
> We can improve {{ObjectUtils.equals}} to handle comparable objects,
>  For example, class A does not implement equals method, but does implements 
> Comparable interface. ObjectUtils.equals() will say its different, but 
> compareTo will say they are equal.
> To handle this, we can change the implementation to something like:
> {code:java}
> //instanceof checks for null, `null instanceof Comparable` is false, so this 
> condition is null safe
>         if (firstValue instanceof Comparable && secondValue instanceof 
> Comparable) {
>             return ((Comparable) firstValue).compareTo(secondValue) == 0;
>         }
>         return Objects.equals(firstValue, secondValue);
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to