### Question:
RegexUtils { public static boolean valueMatchesRegex(String regex, Object value) { if (value instanceof List) { List list = (List) value; for (Object val : list) { if (valueMatchesRegex(regex, val)) { return true; } } } else { if (value != null) { String stringValue = value.toString(); return stringValue != null && stringValue.matches(regex); } } return false; }  static boolean valueMatchesRegex(String regex, Object value);  }### Answer:
@Test public void valueMatchesRegexTest() { assertThat(RegexUtils.valueMatchesRegex("AB.*", "AB_ADMIN"), is(true)); assertThat(RegexUtils.valueMatchesRegex("AB.*", "AA_ADMIN"), is(false)); assertThat(RegexUtils.valueMatchesRegex("99.*", 999), is(true)); assertThat(RegexUtils.valueMatchesRegex("98.*", 999), is(false)); assertThat(RegexUtils.valueMatchesRegex("99\\..*", 99.9), is(true)); assertThat(RegexUtils.valueMatchesRegex("AB.*", null), is(false)); assertThat(RegexUtils.valueMatchesRegex("AB.*", Arrays.asList("AB_ADMIN", "AA_ADMIN")), is(true)); }