@Test public void testStringList() { TestConfig testConfig = createGoodConfig(); testConfig.stringList = testIntegerList; Exception e = expectThrows(IllegalArgumentException.class, () -> ConfigValidation.validateConfig(testConfig)); assertTrue(e.getMessage().contains("stringList")); }
public static void validateConfig(Object config, Class annotationClass) { for (Field field : config.getClass().getDeclaredFields()) { Object value = null; field.setAccessible(true); try { value = field.get(config); } catch (IllegalAccessException e) { throw new RuntimeException(e); } validateField(field, value, annotationClass); } validateClass(config, annotationClass); }
ConfigValidation { public static void validateConfig(Object config, Class annotationClass) { for (Field field : config.getClass().getDeclaredFields()) { Object value = null; field.setAccessible(true); try { value = field.get(config); } catch (IllegalAccessException e) { throw new RuntimeException(e); } validateField(field, value, annotationClass); } validateClass(config, annotationClass); } }
ConfigValidation { public static void validateConfig(Object config, Class annotationClass) { for (Field field : config.getClass().getDeclaredFields()) { Object value = null; field.setAccessible(true); try { value = field.get(config); } catch (IllegalAccessException e) { throw new RuntimeException(e); } validateField(field, value, annotationClass); } validateClass(config, annotationClass); }  }
ConfigValidation { public static void validateConfig(Object config, Class annotationClass) { for (Field field : config.getClass().getDeclaredFields()) { Object value = null; field.setAccessible(true); try { value = field.get(config); } catch (IllegalAccessException e) { throw new RuntimeException(e); } validateField(field, value, annotationClass); } validateClass(config, annotationClass); }  static void validateConfig(Object config, Class annotationClass); static void validateConfig(Object config); static boolean hasConstructor(Class<?> clazz, Class<?> paramClass); }
ConfigValidation { public static void validateConfig(Object config, Class annotationClass) { for (Field field : config.getClass().getDeclaredFields()) { Object value = null; field.setAccessible(true); try { value = field.get(config); } catch (IllegalAccessException e) { throw new RuntimeException(e); } validateField(field, value, annotationClass); } validateClass(config, annotationClass); }  static void validateConfig(Object config, Class annotationClass); static void validateConfig(Object config); static boolean hasConstructor(Class<?> clazz, Class<?> paramClass);  }