XMLUtils { public static Object emptyValue(Class<?> type) { Object defaultValue = null; if (DEFAULTS.containsKey(type)) { defaultValue = DEFAULTS.get(type); } else { try { defaultValue = type.newInstance(); } catch (Exception e) { } } return defaultValue; } private  XMLUtils(); static boolean isSimpleType(Type type); static Object emptyValue(Class<?> type); static final Pattern INDEX_PATTERN; }
@Test void emptyValue() { assertSame(Boolean.FALSE, XMLUtils.emptyValue(boolean.class)); assertSame(TestClass.class, XMLUtils.emptyValue(TestClass.class).getClass()); assertNull(XMLUtils.emptyValue(TestClassWithNoDefaultConstructor.class)); }