AbstractEntityAdjunct extends AbstractBrooklynObject implements BrooklynObjectInternal, EntityAdjunct, Configurable { @Override @Deprecated @SuppressWarnings({ "unchecked", "rawtypes" }) public AbstractEntityAdjunct configure(Map flags) { boolean isFirstTime = true; for (Iterator<Map.Entry> iter = flags.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = iter.next(); if (entry.getKey() instanceof ConfigKey) { ConfigKey key = (ConfigKey)entry.getKey(); if (adjunctType.getConfigKeys().contains(key)) { config().set(key, entry.getValue()); } else { log.warn("Unknown configuration key {} for policy {}; ignoring", key, this); iter.remove(); } } } flags = ConfigUtilsInternal.setAllConfigKeys(flags, getAdjunctType().getConfigKeys(), this); ConfigBag bag = new ConfigBag().putAll(flags); FlagUtils.setFieldsFromFlags(this, bag, isFirstTime); FlagUtils.setAllConfigKeys(this, bag, false); leftoverProperties.putAll(bag.getUnusedConfig()); if (!groovyTruth(name) && leftoverProperties.containsKey("displayName")) { Preconditions.checkArgument(leftoverProperties.get("displayName") instanceof CharSequence, "'displayName' property should be a string"); setDisplayName(leftoverProperties.remove("displayName").toString()); } for (Object flag: leftoverProperties.keySet()) { ConfigKey<Object> key = ConfigKeys.newConfigKey(Object.class, Strings.toString(flag)); if (config().getRaw(key).isPresent()) { log.warn("Config '"+flag+"' on "+this+" conflicts with key already set; ignoring"); } else { config().set(key, leftoverProperties.get(flag)); } } return this; } AbstractEntityAdjunct();  AbstractEntityAdjunct(@SuppressWarnings("rawtypes") Map properties); @Override @Deprecated @SuppressWarnings({ "unchecked", "rawtypes" }) AbstractEntityAdjunct configure(Map flags); @Beta ExecutionContext getExecutionContext(); @Override ConfigurationSupportInternal config(); @Override BasicSubscriptionSupport subscriptions(); @Override T getConfig(ConfigKey<T> key); AdjunctType getAdjunctType(); @Override String getDisplayName(); @Override void setDisplayName(String name); @Override ManagementContext getManagementContext(); void setEntity(EntityLocal entity); Entity getEntity(); void destroy(); @Override boolean isDestroyed(); @Override boolean isRunning(); @Override String getUniqueTag(); @Override TagSupport tags(); @Override Map<String, HighlightTuple> getHighlights(); void setHighlights(Map<String, HighlightTuple> highlights); @Override String toString(); static String HIGHLIGHT_NAME_LAST_ACTION; static String HIGHLIGHT_NAME_LAST_CONFIRMATION; static String HIGHLIGHT_NAME_LAST_VIOLATION; static String HIGHLIGHT_NAME_TRIGGERS; }
@Test public void testImmutableFlags() { TestAdjunct testAdjunct = new TestAdjunct(ImmutableMap.of("unusedKey", "unusedValue")); testAdjunct.configure(ImmutableMap.of("finalKey", "finalValue")); }