Note that containsAny
in the ʻorg.apache.commons.lang3.StringUtils` class has some overloaded methods, but behaves addictively.
The second argument is CharSequence
public static boolean containsAny(final CharSequence cs, final CharSequence searchChars)
The method of is true if any character
contained in the string of the second argument is included.
//Example
StringUtils.containsAny("abcde", "aaa"); // true
StringUtils.containsAny("abcde", "efghi"); // true
The second argument is CharSequence ...
public static boolean containsAny(final CharSequence cs, final CharSequence... searchCharSequences)
The method of is true if any string
contained in the string array of the second argument is included. (This time, the behavior we expected)
//Example
StringUtils.containsAny("abcde", "aaa", "bbb", "ccc"); // false
StringUtils.containsAny("abcde", "cde", "def", "efg"); // true
Although it is a variable argument method, the behavior changes only when the number of arguments is 1
(it looks like), so it seems that variations will increase in the future, so it is notStringUtils.contains ()
butStringUtils.containsAny () Be careful not to get addicted to the simple idea of
making it.
You can call the variable argument method by forcibly casting as follows.
StringUtils.containsAny("abcde", new String[]{"aaa"}); // false
StringUtils.containsAny("abcde", new String[]{"efghi"}); // false
Recommended Posts