commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephan Knitelius (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LANG-974) New StringUtils Method defaulfIfNotIn(String, String, List<String>)
Date Thu, 13 Feb 2014 08:47:19 GMT

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

Stephan Knitelius updated LANG-974:
-----------------------------------

    Description: 
Example use case:
If a Method expects values that should only consist of a certain set such as "0" and "1",
and any Invalid String should be defaulted to "0".

Possible Solution:
{code}
  public static String defaultIfNotIn(final String str, final String defaultString, final
List<String> strIn) {
    if (strIn == null) {
      throw new IllegalArgumentException("strIn cannot be null.");
    }
    if (strIn.contains(str)) {
      return str;
    }
    return defaultString;
  }
{code}

  was:
Example use case:
If a Method expects values that should only consist of a certain set such as "0" and "1",
and any Invalid String should be defaulted to "0".

Possible Solution:
  public static String defaultIfNotIn(final String str, final String defaultString, final
List<String> strIn) {
    if (strIn == null) {
      throw new IllegalArgumentException("strIn cannot be null.");
    }
    if (strIn.contains(str)) {
      return str;
    }
    return defaultString;
  }


> New StringUtils Method defaulfIfNotIn(String, String, List<String>)
> -------------------------------------------------------------------
>
>                 Key: LANG-974
>                 URL: https://issues.apache.org/jira/browse/LANG-974
>             Project: Commons Lang
>          Issue Type: Wish
>          Components: lang.*
>    Affects Versions: 3.2.1
>            Reporter: Stephan Knitelius
>            Priority: Minor
>
> Example use case:
> If a Method expects values that should only consist of a certain set such as "0" and
"1", and any Invalid String should be defaulted to "0".
> Possible Solution:
> {code}
>   public static String defaultIfNotIn(final String str, final String defaultString, final
List<String> strIn) {
>     if (strIn == null) {
>       throw new IllegalArgumentException("strIn cannot be null.");
>     }
>     if (strIn.contains(str)) {
>       return str;
>     }
>     return defaultString;
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message