[
https://issues.apache.org/jira/browse/LANG-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791220#action_12791220
]
Henri Yandell commented on LANG-316:
------------------------------------
I changed the EqualsBuilder method to rely on String.equalsIgnoreCase.
Given the algorithm for equalsIgnoreCase, namely:
lhs == rhs || lhs.toLowerCase().equals(rhs.toLowerCase()) ||
lhs.toUpperCase().equals(rhs.toUpperCase())
I'm not convinced that we can have such a thing for HashCodeBuilder. We don't
know if we should be using lowerCase or upperCase. That then leads to the issue
of two objects that are considered equal, yet have different hashcodes.
Paul also asks in LANG-447 for:
StringUtils.compareToIgnoreCase(s1, s2);
CompareToBuilder.appendIgnoreCase(s1, s2);
The former is probably doable:
isEqualIgnoreCase == true; return 0
otherwise return compareTo on the two Strings.
I'm not entirely convinced though - should the compareTo be looking at
lowercase and uppercase - is it possible for two strings to have uppercase
returning +1 and lowercase returning -1? Probably not an example out there but
might not be something we can guarantee.
The latter method suffers from the issue with HashCodeBuilder. The three
builders need to be in sync, and while CompareToBuilder could easily sit on top
of StringUtils.compareToIgnoreCase (if we can implement that), HashCodeBuilder
would be unable to match it.
I'm leaning towards WONTFIX here.
> Enable CaseInsensitivity in EqualsBuilder and HashCodeBuilder
> -------------------------------------------------------------
>
> Key: LANG-316
> URL: https://issues.apache.org/jira/browse/LANG-316
> Project: Commons Lang
> Issue Type: New Feature
> Affects Versions: 2.3
> Environment: Any
> Reporter: Nelson Carpentier
> Priority: Minor
> Fix For: 3.0
>
> Attachments: lang_20070206.diff, lang_20070529.diff
>
>
> Sometimes I want a String property containing "ThisString" to be seen as
> equal to "THISstring". EqualsBuilder (and HashCodeBuilder) should be
> enhanced to optionally handle this requirement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.