You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2024/11/05 19:07:00 UTC

[jira] [Comment Edited] (LANG-1758) Enable use of compareTo to test for BigDecimal equality in ReflectionDiffBuilder

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

Gary D. Gregory edited comment on LANG-1758 at 11/5/24 7:06 PM:
----------------------------------------------------------------

Hello [~crizzis],

I think any change in behavior should be opt-in which your proposal seems to offer.

This feature might trickle in a few interesting places and we should consider if we need offer a ComparableBuilder that falls back on equals() has a backstop or bake in the Comparable option differently. This needs more think and experimenting. Note that we have {{CompareToBuilder}}.



was (Author: garydgregory):
Hello [~crizzis],

I think any change in behavior should be opt-in which your proposal seems to offer.

This feature might trickle in a few interesting places and we should consider if we need offer a ComparableBuilder that falls back on equals() has a backstop or bake in the Comparable option differently. This needs more think and experimenting.


> Enable use of compareTo to test for BigDecimal equality in ReflectionDiffBuilder
> --------------------------------------------------------------------------------
>
>                 Key: LANG-1758
>                 URL: https://issues.apache.org/jira/browse/LANG-1758
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Krzysztof Sierszeń
>            Priority: Minor
>
> ATM all fields seem to be compared using equals in `org.apache.commons.lang3.builder.ReflectionDiffBuilder`. 
> However, comparing BigDecimals using compareTo (i.e. ignoring precision) is such a common use case, that I feel this could be a configuration option for `ReflectionDiffBuilder`. 
> I can also think of two more generic alternatives:
> #  a config option like `.usingComparatorForType(Class<T>, Comparator<? super T>)`
> # compare *all* `Comparable` types using `compareTo` rather than `equals` (potentially also configurable via an option like `.preferCompareToOverEquals(bool)`



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