Added StringUtils.equalsAny methods and tests.
This commit is contained in:
parent
8d8869f49f
commit
7e8f61ea95
2 changed files with 52 additions and 0 deletions
|
@ -260,6 +260,44 @@ public class StringsUtils
|
||||||
return result;
|
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.
|
* Find longest.
|
||||||
*
|
*
|
||||||
|
|
|
@ -189,4 +189,18 @@ public class StringsUtilsTest
|
||||||
source.set(1, null);
|
source.set(1, null);
|
||||||
Assert.assertTrue(StringsUtils.containsNull(source));
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue