PropertyHelper { @SuppressWarnings("unchecked") public static Collection<String> getMultiValueProperty(Object property) { if (property == null) { return Collections.emptyList(); } else if (property instanceof Collection) { return (Collection<String>)property; } else if (property instanceof String[]) { return Arrays.asList((String[])property); } else { return Collections.singleton(property.toString()); } } private  PropertyHelper(); @SuppressWarnings("unchecked") static Collection<String> getMultiValueProperty(Object property); static String getProperty(Map<String, Object> dict, String name); static String getFirstNonEmptyStringProperty(Map<String, Object> dict, String... keys); static final Logger LOG; }
@Test public void testMultiValuePropertyAsString() { assertEquals(Collections.singleton("hi"), PropertyHelper.getMultiValueProperty("hi")); }
@Test public void testMultiValuePropertyAsArray() { assertEquals(Arrays.asList("a", "b"), PropertyHelper.getMultiValueProperty(new String[]{"a", "b"})); }
@Test public void testMultiValuePropertyAsCollection() { List<String> list = new ArrayList<>(); list.add("1"); list.add("2"); list.add("3"); assertEquals(list, PropertyHelper.getMultiValueProperty(list)); }
@Test public void testMultiValuePropertyNull() { assertTrue(PropertyHelper.getMultiValueProperty(null).isEmpty()); }