commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <>
Subject [jira] Closed: (LANG-652) Added a new equals method tho string utils with signature equals(String, String, boolean)
Date Tue, 28 Sep 2010 03:17:33 GMT


Henri Yandell closed LANG-652.

    Resolution: Won't Fix

The problem is that true->case-sensitive and false->case-insensitive is extremely arbitrary
and there is no reason to expect equals(x, y, true) to mean sensitive instead of insensitive.
Thus we have a general code policy to not have boolean parameters in an API unless it's private
and hidden from the user (to avoid copy and pasted code).

Apologies - basically our consensus has been that equals(x, y, true) is much harder to read
as no one knows what the boolean is for. 

Handling some possible questions in advance:

* Yes equals() isn't called equalsCaseSensitive(); that's because it's a commonly understood
concept in String.equals; and,
* If there are multiple desired boolean parameters we obviously can't bake it into the API
clearly, and I would expect us to use Enums. It's surprisingly rare so far.

> Added a new equals method tho string utils with signature equals(String, String, boolean)
> -----------------------------------------------------------------------------------------
>                 Key: LANG-652
>                 URL:
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>            Reporter: Chris Kujawa
>            Priority: Minor
>             Fix For: 3.1
>         Attachments: kujawa_equalsWithBooleanPatch
>   Original Estimate: 1h
>  Remaining Estimate: 1h
> I added a new equals method the StringUtils that allows users to call one common method
to determine whether two Strings are equal.
> In other words, instead of calling 
>         StringUtils.equals( x, y) for case sensitive comparisons
>     and
>         StringUtils.equalsIgnoreCase( x, y ) for case-insensitive comparisons
>     my addition allows a user to simple call
>         StringUtils.equals( x, y, true) for case-sensitive comparisons
>     or
>         StringUtils.equals(x,y, false) for case-insensitive comparisons
>     I believe this will be cleaner, and much easier to read than having two different
method calls.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message