private static <T> ConfigOption<T> prefixOption(ConfigOption<T> option, String prefix) { String key = prefix + option.key(); List<FallbackKey> deprecatedKeys; if (option.hasFallbackKeys()) { deprecatedKeys = new ArrayList<>(); for (FallbackKey dk : option.fallbackKeys()) { deprecatedKeys.add(createDeprecatedKey(prefix + dk.getKey())); } } else { deprecatedKeys = Collections.emptyList(); } FallbackKey[] deprecated = deprecatedKeys.toArray(new FallbackKey[0]); return new ConfigOption<>(key, option.description(), option.defaultValue(), deprecated); } }
/** * Checks whether there is an entry for the given config option. * * @param configOption The configuration option * * @return <tt>true</tt> if a valid (current or deprecated) key of the config option is stored, * <tt>false</tt> otherwise */ @PublicEvolving public boolean contains(ConfigOption<?> configOption) { synchronized (this.confData){ // first try the current key if (this.confData.containsKey(configOption.key())) { return true; } else if (configOption.hasFallbackKeys()) { // try the fallback keys for (FallbackKey fallbackKey : configOption.fallbackKeys()) { if (this.confData.containsKey(fallbackKey.getKey())) { loggingFallback(fallbackKey, configOption); return true; } } } return false; } }
private Object getRawValueFromOption(ConfigOption<?> configOption) { // first try the current key Object o = getRawValue(configOption.key()); if (o != null) { // found a value for the current proper key return o; } else if (configOption.hasFallbackKeys()) { // try the deprecated keys for (FallbackKey fallbackKey : configOption.fallbackKeys()) { Object oo = getRawValue(fallbackKey.getKey()); if (oo != null) { loggingFallback(fallbackKey, configOption); return oo; } } } return null; }