/** sets _all_ accessible _{@link ConfigKey}_ and {@link HasConfigKey} fields on the given object, * using the indicated flags/config-bag * @deprecated since 0.7.0 use {@link #setAllConfigKeys(Configurable, ConfigBag, boolean)} */ @Deprecated public static void setAllConfigKeys(Configurable o, ConfigBag bag) { setAllConfigKeys(o, bag, false); } /** sets _all_ accessible _{@link ConfigKey}_ and {@link HasConfigKey} fields on the given object,
/** sets _all_ accessible _{@link ConfigKey}_ and {@link HasConfigKey} fields on the given object, * using the indicated flags/config-bag * @deprecated since 0.7.0 use {@link #setAllConfigKeys(Map, Configurable, boolean)} */ @Deprecated public static Map<String, ?> setAllConfigKeys(Map<String, ?> flagsOrConfig, Configurable instance) { return setAllConfigKeys(flagsOrConfig, instance, false); } /** sets _all_ accessible _{@link ConfigKey}_ and {@link HasConfigKey} fields on the given object,
@Override protected void addConfig(RebindContext rebindContext, FeedMemento memento) { // TODO entity does config-lookup differently; the memento contains the config keys. // BasicEntityMemento.postDeserialize uses the injectTypeClass to call EntityTypes.getDefinedConfigKeys(clazz) ConfigBag configBag = ConfigBag.newInstance(memento.getConfig()); FlagUtils.setFieldsFromFlags(feed, configBag); FlagUtils.setAllConfigKeys(feed, configBag, false); }
@Override protected void addConfig(RebindContext rebindContext, EnricherMemento memento) { // TODO entity does config-lookup differently; the memento contains the config keys. // BasicEntityMemento.postDeserialize uses the injectTypeClass to call EntityTypes.getDefinedConfigKeys(clazz) // Note that the flags may have been set in the constructor; but some enrichers have no-arg constructors ConfigBag configBag = ConfigBag.newInstance(memento.getConfig()); FlagUtils.setFieldsFromFlags(enricher, configBag); FlagUtils.setAllConfigKeys(enricher, configBag, false); }
/** sets _all_ accessible _{@link ConfigKey}_ and {@link HasConfigKey} fields on the given object, * using the indicated flags/config-bag */ public static Map<String, ?> setAllConfigKeys(Map<String, ?> flagsOrConfig, Configurable instance, boolean includeFlags) { ConfigBag bag = new ConfigBag().putAll(flagsOrConfig); setAllConfigKeys(instance, bag, includeFlags); return bag.getUnusedConfigMutable(); }
@Test public void testSetAllConfigKeys() { FooCK f = new FooCK(); Map<?,?> unused = FlagUtils.setAllConfigKeys(ImmutableMap.of("f1", 9, "ck1", "do-set", "ck2", "do-set-2", "c3", "do-set"), f, true); assertEquals(f.bag.get(FooCK.CK1), "do-set"); assertEquals(f.bag.get(FooCK.CK3), "do-set"); assertEquals(f.bag.containsKey(FooCK.CK2), true); assertEquals(f.bag.get(FooCK.CK2), "do-set-2"); assertEquals(unused, ImmutableMap.of("f1", 9)); }
@Override protected void addConfig(RebindContext rebindContext, PolicyMemento memento) { // TODO entity does config-lookup differently; the memento contains the config keys. // BasicEntityMemento.postDeserialize uses the injectTypeClass to call EntityTypes.getDefinedConfigKeys(clazz) Collection<ConfigKey<?>> configKeys = policy.getAdjunctType().getConfigKeys(); Map<?, ?> flags = memento.getConfig(); // First set the config keys that are known explicitly (including with deprecated names). flags = ConfigUtilsInternal.setAllConfigKeys(flags, configKeys, policy); // Note that the flags may have been set in the constructor; but non-legacy policies should have no-arg constructors if (!flags.isEmpty()) { ConfigBag configBag = ConfigBag.newInstance(flags); FlagUtils.setFieldsFromFlags(policy, configBag); FlagUtils.setAllConfigKeys(policy, configBag, false); } }
FlagUtils.setAllConfigKeys(this, bag, false); leftoverProperties.putAll(bag.getUnusedConfig());
flags = FlagUtils.setAllConfigKeys(flags, this, false);
FlagUtils.setAllConfigKeys(this, configBag, false);