commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pascal Schumacher (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LANG-1306) Add nullToEmpty method in StringUtils
Date Thu, 20 Apr 2017 17:31:04 GMT

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

Pascal Schumacher updated LANG-1306:
------------------------------------
    Fix Version/s:     (was: 3.6)

> Add nullToEmpty method in StringUtils
> -------------------------------------
>
>                 Key: LANG-1306
>                 URL: https://issues.apache.org/jira/browse/LANG-1306
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>            Reporter: Arshad Basha
>            Priority: Minor
>
> The nullToEmpty method will convert null reference to empty string, for non null str
it will return the str as it is (i.e. without striping or removing space)
> This method doesn't strips white-space nor removes control characters from the start
and end of the input string like StringUtils.stripToEmpty and StringUtils.trimToEmpty methods.
> This method will allow us to replace common code patterns like the following from client
side code:
> 1) if(str == null) {   str = "";  }
> 2) return str == null ? "" : str;
> Examples:
>         assertEquals("", StringUtils.nullToEmpty(null));
>         assertEquals("", StringUtils.nullToEmpty(""));
>         assertEquals("abc", StringUtils.nullToEmpty("abc"));
>         assertEquals("  abc", StringUtils.nullToEmpty("  abc"));
>         assertEquals("abc  ", StringUtils.nullToEmpty("abc  "));
>         assertEquals("abc\t", StringUtils.nullToEmpty("abc\t"));



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message