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

[jira] [Reopened] (LANG-875) StringUtils: Include methods for appending suffix or prepending a prefix if not already present

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

Sebb reopened LANG-875:
-----------------------


The code currently behaves differently for the following two cases:

StringUtils.appendIfMissing("","xyz",(CharSequence[]) null); // => "xyz"
StringUtils.appendIfMissing("","xyz",(CharSequence) null); // => ""

Is that to be expected?

If so, it should be documented and tested, otherwise it should be fixed (and tested).

Note: this was discovered when investigating the Eclipse warning for the current test code, which uses:

StringUtils.appendIfMissing("","xyz",null);

Eclipse complains:

The argument of type null should explicitly be cast to CharSequence[] for the invocation of the varargs method appendIfMissing(String, CharSequence, CharSequence...) from type StringUtils. It could alternatively be cast to CharSequence for a varargs invocation
                
> StringUtils: Include methods for appending suffix or prepending a prefix if not already present
> -----------------------------------------------------------------------------------------------
>
>                 Key: LANG-875
>                 URL: https://issues.apache.org/jira/browse/LANG-875
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Joanne Polsky
>            Priority: Minor
>             Fix For: 3.2
>
>         Attachments: LANG-875-noany.patch, LANG-875.patch
>
>
> StringUtils has various methods to checking and removing a substring from the start/end of a string but nothing for appending.  These methods will append a suffix to the end or prepend a prefix to the start of the string if not already present.
> The methods would include:
> - appendIfMissing
> - appendIfMissingAny
> - appendIfMissingIgnoreCase
> - appendIfMissingAnyIgnoreCase
> - prependIfMissing
> - prependIfMissingAny
> - prependIfMissingIgnoreCase
> - prependIfMissingAnyIgnoreCase

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira