@Test public void testCreateConfig() { configStore.addConfigFactory(new MockConfigFactory(BasicConfig.class, "config1")); configStore.createConfig("config1", BasicConfig.class); assertThat(configStore.getConfigClasses("config1"), hasSize(1)); assertThat(configStore.getSubjects(String.class, BasicConfig.class), hasSize(1)); assertThat(configStore.getSubjects(String.class), hasSize(1)); BasicConfig queried = configStore.getConfig("config1", BasicConfig.class); assertThat(queried, notNullValue()); configStore.clearConfig("config1", BasicConfig.class); assertThat(configStore.getConfigClasses("config1"), hasSize(0)); assertThat(configStore.getSubjects(String.class, BasicConfig.class), hasSize(0)); assertThat(configStore.getSubjects(String.class), hasSize(0)); BasicConfig queriedAfterClear = configStore.getConfig("config1", BasicConfig.class); assertThat(queriedAfterClear, nullValue()); }
@Override public <S, C extends Config<S>> C createConfig(S subject, Class<C> configClass) { ConfigFactory<S, C> factory = getConfigFactory(configClass); Versioned<JsonNode> json = configs.computeIfAbsent(key(subject, configClass), k -> factory.isList() ? mapper.createArrayNode() : mapper.createObjectNode()); return createConfig(subject, configClass, json.value()); }
DistributedNetworkConfigStore extends AbstractStore<NetworkConfigEvent, NetworkConfigStoreDelegate> implements NetworkConfigStore { @Override public <S, C extends Config<S>> C createConfig(S subject, Class<C> configClass) { ConfigFactory<S, C> factory = getConfigFactory(configClass); Versioned<JsonNode> json = configs.computeIfAbsent(key(subject, configClass), k -> factory.isList() ? mapper.createArrayNode() : mapper.createObjectNode()); return createConfig(subject, configClass, json.value()); } }
DistributedNetworkConfigStore extends AbstractStore<NetworkConfigEvent, NetworkConfigStoreDelegate> implements NetworkConfigStore { @Override public <S, C extends Config<S>> C createConfig(S subject, Class<C> configClass) { ConfigFactory<S, C> factory = getConfigFactory(configClass); Versioned<JsonNode> json = configs.computeIfAbsent(key(subject, configClass), k -> factory.isList() ? mapper.createArrayNode() : mapper.createObjectNode()); return createConfig(subject, configClass, json.value()); }  }
DistributedNetworkConfigStore extends AbstractStore<NetworkConfigEvent, NetworkConfigStoreDelegate> implements NetworkConfigStore { @Override public <S, C extends Config<S>> C createConfig(S subject, Class<C> configClass) { ConfigFactory<S, C> factory = getConfigFactory(configClass); Versioned<JsonNode> json = configs.computeIfAbsent(key(subject, configClass), k -> factory.isList() ? mapper.createArrayNode() : mapper.createObjectNode()); return createConfig(subject, configClass, json.value()); }  @Activate void activate(); @Deactivate void deactivate(); @Override void addConfigFactory(ConfigFactory configFactory); @Override void removeConfigFactory(ConfigFactory configFactory); @Override @SuppressWarnings("unchecked") ConfigFactory<S, C> getConfigFactory(Class<C> configClass); @Override @SuppressWarnings("unchecked") Set<S> getSubjects(Class<S> subjectClass); @Override @SuppressWarnings("unchecked") Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass); @Override @SuppressWarnings("unchecked") Set<Class<? extends Config<S>>> getConfigClasses(S subject); @Override T getConfig(S subject, Class<T> configClass); @Override C createConfig(S subject, Class<C> configClass); @Override C applyConfig(S subject, Class<C> configClass, JsonNode json); @Override void queueConfig(S subject, String configKey, JsonNode json); @Override void clearConfig(S subject, Class<C> configClass); @Override void clearQueuedConfig(S subject, String configKey); @Override void clearConfig(S subject); @Override void clearConfig(); }
DistributedNetworkConfigStore extends AbstractStore<NetworkConfigEvent, NetworkConfigStoreDelegate> implements NetworkConfigStore { @Override public <S, C extends Config<S>> C createConfig(S subject, Class<C> configClass) { ConfigFactory<S, C> factory = getConfigFactory(configClass); Versioned<JsonNode> json = configs.computeIfAbsent(key(subject, configClass), k -> factory.isList() ? mapper.createArrayNode() : mapper.createObjectNode()); return createConfig(subject, configClass, json.value()); }  @Activate void activate(); @Deactivate void deactivate(); @Override void addConfigFactory(ConfigFactory configFactory); @Override void removeConfigFactory(ConfigFactory configFactory); @Override @SuppressWarnings("unchecked") ConfigFactory<S, C> getConfigFactory(Class<C> configClass); @Override @SuppressWarnings("unchecked") Set<S> getSubjects(Class<S> subjectClass); @Override @SuppressWarnings("unchecked") Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass); @Override @SuppressWarnings("unchecked") Set<Class<? extends Config<S>>> getConfigClasses(S subject); @Override T getConfig(S subject, Class<T> configClass); @Override C createConfig(S subject, Class<C> configClass); @Override C applyConfig(S subject, Class<C> configClass, JsonNode json); @Override void queueConfig(S subject, String configKey, JsonNode json); @Override void clearConfig(S subject, Class<C> configClass); @Override void clearQueuedConfig(S subject, String configKey); @Override void clearConfig(S subject); @Override void clearConfig();  }