commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Meyffret (JIRA)" <>
Subject [jira] [Created] (LANG-1113) Manages Comparable in EqualsBuilder
Date Fri, 10 Apr 2015 18:44:13 GMT
Simon Meyffret created LANG-1113:

             Summary: Manages Comparable in EqualsBuilder
                 Key: LANG-1113
             Project: Commons Lang
          Issue Type: New Feature
          Components: lang.builder.*
            Reporter: Simon Meyffret
            Priority: Trivial

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

For example:
    return new EqualsBuilder()
        .appendComparable(this.amount, other.amount)

    public EqualsBuilder appendComparable(Comparable lhs, Comparable rhs) {
        int c = new CompareToBuilder()
                .append(lhs, rhs) // manages null
        return append(c, 0);

This message was sent by Atlassian JIRA

View raw message