diff --git a/src/fr/devinsy/util/strings/StringsUtils.java b/src/fr/devinsy/util/strings/StringsUtils.java index 022a296..8b93c1e 100644 --- a/src/fr/devinsy/util/strings/StringsUtils.java +++ b/src/fr/devinsy/util/strings/StringsUtils.java @@ -104,6 +104,44 @@ public class StringsUtils return result; } + /** + * Contains any. + * + * @param token + * the token + * @param strings + * the strings + * @return true, if successful + */ + public static boolean containsAny(final String token, final String... strings) + { + boolean result; + + result = new StringList(strings).contains(token); + + // + return result; + } + + /** + * Contains any ignore case. + * + * @param token + * the token + * @param strings + * the strings + * @return true, if successful + */ + public static boolean containsAnyIgnoreCase(final String token, final String... strings) + { + boolean result; + + result = new StringList(strings).containsIgnoreCase(token); + + // + return result; + } + /** * Contains blank. * diff --git a/test/fr/devinsy/util/strings/StringsUtilsTest.java b/test/fr/devinsy/util/strings/StringsUtilsTest.java index c46d2a1..4a98af6 100644 --- a/test/fr/devinsy/util/strings/StringsUtilsTest.java +++ b/test/fr/devinsy/util/strings/StringsUtilsTest.java @@ -47,6 +47,27 @@ public class StringsUtilsTest Logger.getRootLogger().setLevel(Level.ERROR); } + /** + * Test contains any 01. + */ + @Test + public void testContainsAny01() + { + Assert.assertTrue(StringsUtils.containsAny("abc", "aaa", "bbb", "abc")); + Assert.assertFalse(StringsUtils.containsAny("abc", "aaa", "bbb", "aBc")); + } + + /** + * Test contains any ignore case 01. + */ + @Test + public void testContainsAnyIgnoreCase01() + { + Assert.assertTrue(StringsUtils.containsAnyIgnoreCase("abc", "aaa", "bbb", "abc")); + Assert.assertTrue(StringsUtils.containsAnyIgnoreCase("abc", "aaa", "bbb", "aBc")); + Assert.assertFalse(StringsUtils.containsAnyIgnoreCase("abc", "aaa", "bbb", "ccc")); + } + /** * Test contains blank 01. */