@Test public void testSetConfig() throws IOException { AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now()); accountSession.setUsername("test"); TestConfig conf = manager.getConfig(TestConfig.class); conf.key("new value"); Assert.assertEquals("new value", conf.key()); }
public <T> T getConfig(Class<T> clazz) { if (!Modifier.isPublic(clazz.getModifiers())) { throw new RuntimeException("Non-public configuration classes can't have default methods invoked"); } T t = (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz }, handler); return t; }
ConfigManager { public <T> T getConfig(Class<T> clazz) { if (!Modifier.isPublic(clazz.getModifiers())) { throw new RuntimeException("Non-public configuration classes can't have default methods invoked"); } T t = (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz }, handler); return t; } }
ConfigManager { public <T> T getConfig(Class<T> clazz) { if (!Modifier.isPublic(clazz.getModifiers())) { throw new RuntimeException("Non-public configuration classes can't have default methods invoked"); } T t = (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz }, handler); return t; } ConfigManager(); }
ConfigManager { public <T> T getConfig(Class<T> clazz) { if (!Modifier.isPublic(clazz.getModifiers())) { throw new RuntimeException("Non-public configuration classes can't have default methods invoked"); } T t = (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz }, handler); return t; } ConfigManager(); final void switchSession(AccountSession session); void load(); T getConfig(Class<T> clazz); String getConfiguration(String groupName, String key); T getConfiguration(String groupName, String key, Class<T> clazz); void setConfiguration(String groupName, String key, String value); void setConfiguration(String groupName, String key, Object value); void unsetConfiguration(String groupName, String key); ConfigDescriptor getConfigDescriptor(Object configurationProxy); void setDefaultConfiguration(Object proxy, boolean override); }
ConfigManager { public <T> T getConfig(Class<T> clazz) { if (!Modifier.isPublic(clazz.getModifiers())) { throw new RuntimeException("Non-public configuration classes can't have default methods invoked"); } T t = (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz }, handler); return t; } ConfigManager(); final void switchSession(AccountSession session); void load(); T getConfig(Class<T> clazz); String getConfiguration(String groupName, String key); T getConfiguration(String groupName, String key, Class<T> clazz); void setConfiguration(String groupName, String key, String value); void setConfiguration(String groupName, String key, Object value); void unsetConfiguration(String groupName, String key); ConfigDescriptor getConfigDescriptor(Object configurationProxy); void setDefaultConfiguration(Object proxy, boolean override);  }