You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Benedikt Ritter (JIRA)" <ji...@apache.org> on 2015/04/18 20:16:58 UTC

[jira] [Updated] (LANG-1113) Manages Comparable in EqualsBuilder

     [ https://issues.apache.org/jira/browse/LANG-1113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benedikt Ritter updated LANG-1113:
----------------------------------
    Fix Version/s: Discussion

> Manages Comparable in EqualsBuilder
> -----------------------------------
>
>                 Key: LANG-1113
>                 URL: https://issues.apache.org/jira/browse/LANG-1113
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.builder.*
>            Reporter: Simon Meyffret
>            Priority: Trivial
>              Labels: BigDecimal, EqualsBuilder
>             Fix For: Discussion
>
>
> As explained by LANG-393 and LANG-467, {{EqualsBuilder}} fails to provide a proper way to handle {{BigDecimal}} since {{BigDecimal}} takes the scale into account when using {{equals()}} but not with {{compareTo()}}.
> Would it be possible to add a method *{{appendComparable()}}* in {{EqualsBuilder}} to manages {{Comparable}} objects when we want to build equality on {{compareTo()}} and not {{equals()}}?
> Making clear that {{EqualsBuilder}} is not compliant with {{HashCodeBuilder}} when using this method.
> For example:
> {code:borderStyle=solid}
>     return new EqualsBuilder()
>         .append(this.name, other.name)
>         .appendComparable(this.amount, other.amount)
>         .isEqual();
> {code}
> with:
> {code:title=EqualsBuilder.java|borderStyle=solid}
>     public EqualsBuilder appendComparable(Comparable lhs, Comparable rhs) {
>         int c = new CompareToBuilder()
>                 .append(lhs, rhs) // manages null
>                 .toComparison();
>         return append(c, 0);
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)