@Override public ConfigKey<?> getConfigKey(String name) { return delegate.getConfigKey(name); }
@Override public Set<ConfigKey<?>> getConfigKeys() { return delegate.getConfigKeys(); }
@Override public String getName() { return delegate.getName(); }
@Override public int hashCode() { return delegate.hashCode(); }
private AdjunctType(Class<? extends EntityAdjunct> clazz, AbstractEntityAdjunct adjunct) { name = clazz.getCanonicalName(); configKeys = Collections.unmodifiableMap(findConfigKeys(clazz, null)); configKeysSet = ImmutableSet.copyOf(this.configKeys.values()); if (LOG.isTraceEnabled()) LOG.trace("Policy {} config keys: {}", name, Joiner.on(", ").join(configKeys.keySet())); }
Field definitiveField = alternativeField != null ? inferSubbestField(alternativeField, f) : f; boolean skip = false; if (definitiveField != f) {
@Override public int hashCode() { return delegate.hashCode(); }
@Override public Set<ConfigKey<?>> getConfigKeys() { return delegate.getConfigKeys(); }
@Override public ConfigKey<?> getConfigKey(String name) { return delegate.getConfigKey(name); }
@Override public String getName() { return delegate.getName(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof PolicyType)) return false; PolicyType o = (PolicyType) obj; return Objects.equal(name, o.getName()) && Objects.equal(getConfigKeys(), o.getConfigKeys()); }
@SuppressWarnings("unchecked") @Override public <T> T getConfig(ConfigKey<T> key, T defaultValue) { // FIXME What about inherited task in config?! // alex says: think that should work, no? // FIXME What if someone calls getConfig on a task, before setting parent app? // alex says: not supported (throw exception, or return the task) // In case this entity class has overridden the given key (e.g. to set default), then retrieve this entity's key // TODO If ask for a config value that's not in our configKeys, should we really continue with rest of method and return key.getDefaultValue? // e.g. SshBasedJavaAppSetup calls setAttribute(JMX_USER), which calls getConfig(JMX_USER) // but that example doesn't have a default... ConfigKey<T> ownKey = adjunct!=null ? (ConfigKey<T>)elvis(adjunct.getAdjunctType().getConfigKey(key.getName()), key) : key; // Don't use groovy truth: if the set value is e.g. 0, then would ignore set value and return default! if (ownKey instanceof ConfigKeySelfExtracting) { if (((ConfigKeySelfExtracting<T>)ownKey).isSet(ownConfig)) { // FIXME Should we support config from futures? How to get execution context before setEntity? EntityLocal entity = adjunct.entity; ExecutionContext exec = (entity != null) ? ((EntityInternal)entity).getExecutionContext() : null; return ((ConfigKeySelfExtracting<T>)ownKey).extractValue(ownConfig, exec); } } else { LOG.warn("Config key {} of {} is not a ConfigKeySelfExtracting; cannot retrieve value; returning default", ownKey, this); } return TypeCoercions.coerce((defaultValue != null) ? defaultValue : ownKey.getDefaultValue(), key.getTypeToken()); }
if (entry.getKey() instanceof ConfigKey) { ConfigKey key = (ConfigKey)entry.getKey(); if (adjunctType.getConfigKeys().contains(key)) { setConfig(key, entry.getValue()); } else {