ConfigUtils { @SuppressWarnings("rawtypes") public static Set<HasConfigKey<?>> getStaticKeysOnClass(Class<?> type) { Set<HasConfigKey<?>> result = new LinkedHashSet<ConfigKey.HasConfigKey<?>>(); for (Field f: type.getFields()) { try { if ((f.getModifiers() & Modifier.STATIC)==0) continue; if (ConfigKey.class.isAssignableFrom(f.getType())) result.add(new WrappedConfigKey((ConfigKey<?>) f.get(null))); else if (HasConfigKey.class.isAssignableFrom(f.getType())) result.add((HasConfigKey<?>) f.get(null)); } catch (Exception e) { log.error("Error retrieving config key for field "+f+" on class "+type+"; rethrowing", e); throw Exceptions.propagate(e); } } return Collections.unmodifiableSet(result); }  static T getRequiredConfig(Entity entity, ConfigKey<T> key); static ConfigKey<T> prefixedKey(String prefix, ConfigKey<T> key); static ConfigKey<T> unprefixedKey(String prefix, ConfigKey<T> key); static BrooklynProperties loadFromFile(String file); static BrooklynProperties filterFor(BrooklynProperties properties, Predicate<? super String> filter); static BrooklynProperties filterForPrefix(BrooklynProperties properties, String prefix); static BrooklynProperties filterForPrefixAndStrip(Map<String,?> properties, String prefix); @SuppressWarnings("rawtypes") static Set<HasConfigKey<?>> getStaticKeysOnClass(Class<?> type); static void addUnprefixedConfigKeyInConfigBack(String configPrefix, ConfigBag configBag, Map<String, Object> destinationBucket);  }
@Test public void testGetStaticKeys() { Set<HasConfigKey<?>> keys = ConfigUtils.getStaticKeysOnClass(ConfigUtilsTest.class); if (keys.size()!=1) Assert.fail("Expected 1 key; got: "+keys); Assert.assertEquals(keys.iterator().next().getConfigKey(), S1); }