FileNameUtil { @SuppressWarnings("unchecked") static List<String> getAsList(Object values) { if (values == null) { return new ArrayList<>(); } if (values instanceof String) { return Lists.newArrayList((String) values); } else if (values instanceof List) { return (List<String>) values; } else { throw new IllegalArgumentException("includes or excludes must be a String or a List<String> but is a " + values.getClass()); } } private  FileNameUtil(); static List<File> identifyFiles(Map parameters); static boolean isIncluded(String name, Map parameters); static boolean matches(String name, List<String> patterns, boolean defaultValue); static boolean matches(String name, String pattern); static String getParentPath(String fileName); static String getCanonicalPath(String path);  }
@Test public void testGetAsArray() { assertThat(FileNameUtil.getAsList(null), hasSize(0)); assertThat(FileNameUtil.getAsList(""), CoreMatchers.is(Lists.newArrayList(""))); assertThat(FileNameUtil.getAsList(Lists.newArrayList("a", "b", "c")), CoreMatchers.is(Lists.newArrayList("a", "b", "c"))); try { assertThat(FileNameUtil.getAsList(12L), nullValue()); fail("IllegalArgumentException expected"); } catch(IllegalArgumentException e) { assertThat(e.getMessage(), CoreMatchers.is("includes or excludes must be a String or a List<String> but is a class java.lang.Long")); } }