Stephan Knitelius created LANG-974:
--------------------------------------
Summary: 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:
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;
}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)