Commit 7e8f61ea authored by Christian P. MOMON's avatar Christian P. MOMON
Browse files

Added StringUtils.equalsAny methods and tests.

parent 8d8869f4
......@@ -260,6 +260,44 @@ public class StringsUtils
return result;
}
/**
* Checks if is contained.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if is contained
*/
public static boolean equalsAny(final String token, final String... strings)
{
boolean result;
result = new StringList(strings).contains(token);
//
return result;
}
/**
* Checks if is contained ignore case.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if is contained ignore case
*/
public static boolean equalsAnyIgnoreCase(final String token, final String... strings)
{
boolean result;
result = new StringList(strings).containsIgnoreCase(token);
//
return result;
}
/**
* Find longest.
*
......
......@@ -189,4 +189,18 @@ public class StringsUtilsTest
source.set(1, null);
Assert.assertTrue(StringsUtils.containsNull(source));
}
@Test
public void testIsContained01()
{
Assert.assertTrue(StringsUtils.equalsAny("abc", "aaa", "bbb", "abc"));
Assert.assertFalse(StringsUtils.equalsAny("abc", "aaa", "bbb", "aBc"));
}
@Test
public void testIsContainedIgnoreCase01()
{
Assert.assertTrue(StringsUtils.equalsAnyIgnoreCase("abc", "aaa", "bbb", "abc"));
Assert.assertTrue(StringsUtils.equalsAnyIgnoreCase("abc", "aaa", "bbb", "aBc"));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment