Added containsAny and containsAnyIgnoreCase method and tests.

This commit is contained in:
Christian P. MOMON 2017-12-28 04:47:52 +01:00
parent 03ca464d95
commit a693da1fb8
2 changed files with 59 additions and 0 deletions

View file

@ -104,6 +104,44 @@ public class StringsUtils
return result; 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. * Contains blank.
* *

View file

@ -47,6 +47,27 @@ public class StringsUtilsTest
Logger.getRootLogger().setLevel(Level.ERROR); 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. * Test contains blank 01.
*/ */