ReflectionUtil { public static Set<ConfigKey<?>> getAllConfigsProduced(Class<? extends ConfigProducer> producerClass, String configId) { TypeToken<? extends ConfigProducer>.TypeSet interfaces = TypeToken.of(producerClass).getTypes().interfaces(); return interfaces.rawTypes().stream() .filter(ReflectionUtil::isConcreteProducer) .map(i -> createConfigKeyFromInstance(i.getEnclosingClass(), configId)) .collect(Collectors.toSet()); } private  ReflectionUtil(); static Set<ConfigKey<?>> getAllConfigsProduced(Class<? extends ConfigProducer> producerClass, String configId); static boolean hasRestartMethods(Class<? extends ConfigInstance> configClass); static boolean containsFieldsFlaggedWithRestart(Class<? extends ConfigInstance> configClass); static ChangesRequiringRestart getChangesRequiringRestart(ConfigInstance from, ConfigInstance to); static List<Class<?>> getAllSuperclasses(Class<?> cls);  }
@Test public void getAllConfigsProduced_includes_configs_produced_by_super_class() { Set<ConfigKey<?>> configs = getAllConfigsProduced(ConcreteProducer.class, "foo"); assertThat(configs.size(), is(1)); assertTrue(configs.contains(new ConfigKey<>(SimpletypesConfig.CONFIG_DEF_NAME, "foo", SimpletypesConfig.CONFIG_DEF_NAMESPACE))); }
@Test public void getAllConfigsProduced_includes_configs_produced_by_implemented_interface() { Set<ConfigKey<?>> configs = getAllConfigsProduced(InterfaceImplementingProducer.class, "foo"); assertThat(configs.size(), is(2)); assertTrue(configs.contains(new ConfigKey<>(SimpletypesConfig.CONFIG_DEF_NAME, "foo", SimpletypesConfig.CONFIG_DEF_NAMESPACE))); assertTrue(configs.contains(new ConfigKey<>(ArraytypesConfig.CONFIG_DEF_NAME, "foo", ArraytypesConfig.CONFIG_DEF_NAMESPACE))); }
@Test public void getAllConfigsProduced_includes_configs_directly_implemented_by_producer() { Set<ConfigKey<?>> configs = getAllConfigsProduced(SimpleProducer.class, "foo"); assertThat(configs.size(), is(1)); assertTrue(configs.contains(new ConfigKey<>(SimpletypesConfig.CONFIG_DEF_NAME, "foo", SimpletypesConfig.CONFIG_DEF_NAMESPACE))); }