/** * Removes given config option from the configuration. * * @param configOption config option to remove * @param <T> Type of the config option * @return true is config has been removed, false otherwise */ public <T> boolean removeConfig(ConfigOption<T> configOption){ synchronized (this.confData){ // try the current key Object oldValue = this.confData.remove(configOption.key()); if (oldValue == null){ for (String deprecatedKey : configOption.deprecatedKeys()){ oldValue = this.confData.remove(deprecatedKey); if (oldValue != null){ LOG.warn("Config uses deprecated configuration key '{}' instead of proper key '{}'", deprecatedKey, configOption.key()); return true; } } return false; } return true; } }
private static <T> ConfigOption<T> prefixOption(ConfigOption<T> option, String prefix) { String key = prefix + option.key(); List<String> deprecatedKeys; if (option.hasDeprecatedKeys()) { deprecatedKeys = new ArrayList<>(); for (String dk : option.deprecatedKeys()) { deprecatedKeys.add(prefix + dk); } } else { deprecatedKeys = Collections.emptyList(); } String[] deprecated = deprecatedKeys.toArray(new String[deprecatedKeys.size()]); return new ConfigOption<>(key, option.description(), option.defaultValue(), deprecated); } }
private static <T> ConfigOption<T> prefixOption(ConfigOption<T> option, String prefix) { String key = prefix + option.key(); List<String> deprecatedKeys; if (option.hasDeprecatedKeys()) { deprecatedKeys = new ArrayList<>(); for (String dk : option.deprecatedKeys()) { deprecatedKeys.add(prefix + dk); } } else { deprecatedKeys = Collections.emptyList(); } String[] deprecated = deprecatedKeys.toArray(new String[deprecatedKeys.size()]); 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.hasDeprecatedKeys()) { // try the deprecated keys for (String deprecatedKey : configOption.deprecatedKeys()) { if (this.confData.containsKey(deprecatedKey)) { LOG.warn("Config uses deprecated configuration key '{}' instead of proper key '{}'", deprecatedKey, configOption.key()); return true; } } } return false; } }
/** * 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.hasDeprecatedKeys()) { // try the deprecated keys for (String deprecatedKey : configOption.deprecatedKeys()) { if (this.confData.containsKey(deprecatedKey)) { LOG.warn("Config uses deprecated configuration key '{}' instead of proper key '{}'", deprecatedKey, configOption.key()); 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.hasDeprecatedKeys()) { // try the deprecated keys for (String deprecatedKey : configOption.deprecatedKeys()) { Object oo = getRawValue(deprecatedKey); if (oo != null) { LOG.warn("Config uses deprecated configuration key '{}' instead of proper key '{}'", deprecatedKey, configOption.key()); return oo; } } } return null; }
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.hasDeprecatedKeys()) { // try the deprecated keys for (String deprecatedKey : configOption.deprecatedKeys()) { Object oo = getRawValue(deprecatedKey); if (oo != null) { LOG.warn("Config uses deprecated configuration key '{}' instead of proper key '{}'", deprecatedKey, configOption.key()); return oo; } } } return null; }