/** * Creates a string-valued option with no default value. * String-valued options are the only ones that can have no * default value. * * @return The created ConfigOption. */ public ConfigOption<String> noDefaultValue() { return new ConfigOption<>(key, null); } }
/** * Creates a new config option, using this option's key and default value, and * adding the given description. The given description is used when generation the configuration documention. * * @param description The description for this option. * @return A new config option, with given description. */ public ConfigOption<T> withDescription(final Description description) { return new ConfigOption<>(key, description, defaultValue, fallbackKeys); }
/** * Creates a new config option, using this option's key and default value, and * adding the given deprecated keys. * * <p>When obtaining a value from the configuration via {@link Configuration#getValue(ConfigOption)}, * the deprecated keys will be checked in the order provided to this method. The first key for which * a value is found will be used - that value will be returned. * * @param deprecatedKeys The deprecated keys, in the order in which they should be checked. * @return A new config options, with the given deprecated keys. */ public ConfigOption<T> withDeprecatedKeys(String... deprecatedKeys) { FallbackKey[] fallbackKeys = Arrays.stream(deprecatedKeys) .map(FallbackKey::createDeprecatedKey) .toArray(FallbackKey[]::new); return new ConfigOption<>(key, description, defaultValue, fallbackKeys); }
/** * Creates a new config option, using this option's key and default value, and * adding the given fallback keys. * * <p>When obtaining a value from the configuration via {@link Configuration#getValue(ConfigOption)}, * the fallback keys will be checked in the order provided to this method. The first key for which * a value is found will be used - that value will be returned. * * @param fallbackKeys The fallback keys, in the order in which they should be checked. * @return A new config options, with the given fallback keys. */ public ConfigOption<T> withFallbackKeys(String... fallbackKeys) { FallbackKey[] fallbackKeyArray = Arrays.stream(fallbackKeys) .map(FallbackKey::createFallbackKey) .toArray(FallbackKey[]::new); return new ConfigOption<>(key, description, defaultValue, fallbackKeyArray); }
/** * Creates a ConfigOption with the given default value. * * <p>This method does not accept "null". For options with no default value, choose * one of the {@code noDefaultValue} methods. * * @param value The default value for the config option * @param <T> The type of the default value. * @return The config option with the default value. */ public <T> ConfigOption<T> defaultValue(T value) { checkNotNull(value); return new ConfigOption<>(key, value); }
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); } }
/** * Creates a new config option, using this option's key and default value, and * adding the given description. The given description is used when generation the configuration documention. * * <p><b>NOTE:</b> You can use html to format the output of the generated cell. * * @param description The description for this option. * @return A new config option, with given description. */ public ConfigOption<T> withDescription(final String description) { return new ConfigOption<>(key, description, defaultValue, deprecatedKeys); }
/** * Creates a string-valued option with no default value. * String-valued options are the only ones that can have no * default value. * * @return The created ConfigOption. */ public ConfigOption<String> noDefaultValue() { return new ConfigOption<>(key, null); } }
/** * Creates a string-valued option with no default value. * String-valued options are the only ones that can have no * default value. * * @return The created ConfigOption. */ public ConfigOption<String> noDefaultValue() { return new ConfigOption<>(key, null); } }
/** * Creates a new config option, using this option's key and default value, and * adding the given description. The given description is used when generation the configuration documention. * * @param description The description for this option. * @return A new config option, with given description. */ public ConfigOption<T> withDescription(final Description description) { return new ConfigOption<>(key, description, defaultValue, deprecatedKeys); }
/** * Creates a new config option, using this option's key and default value, and * adding the given deprecated keys. * * <p>When obtaining a value from the configuration via {@link Configuration#getValue(ConfigOption)}, * the deprecated keys will be checked in the order provided to this method. The first key for which * a value is found will be used - that value will be returned. * * @param deprecatedKeys The deprecated keys, in the order in which they should be checked. * @return A new config options, with the given deprecated keys. */ public ConfigOption<T> withDeprecatedKeys(String... deprecatedKeys) { return new ConfigOption<>(key, description, defaultValue, deprecatedKeys); }
/** * Creates a new config option, using this option's key and default value, and * adding the given deprecated keys. * * <p>When obtaining a value from the configuration via {@link Configuration#getValue(ConfigOption)}, * the deprecated keys will be checked in the order provided to this method. The first key for which * a value is found will be used - that value will be returned. * * @param deprecatedKeys The deprecated keys, in the order in which they should be checked. * @return A new config options, with the given deprecated keys. */ public ConfigOption<T> withDeprecatedKeys(String... deprecatedKeys) { return new ConfigOption<>(key, description, defaultValue, deprecatedKeys); }
/** * Creates a ConfigOption with the given default value. * * <p>This method does not accept "null". For options with no default value, choose * one of the {@code noDefaultValue} methods. * * @param value The default value for the config option * @param <T> The type of the default value. * @return The config option with the default value. */ public <T> ConfigOption<T> defaultValue(T value) { checkNotNull(value); return new ConfigOption<>(key, value); }
/** * Creates a ConfigOption with the given default value. * * <p>This method does not accept "null". For options with no default value, choose * one of the {@code noDefaultValue} methods. * * @param value The default value for the config option * @param <T> The type of the default value. * @return The config option with the default value. */ public <T> ConfigOption<T> defaultValue(T value) { checkNotNull(value); return new ConfigOption<>(key, value); }
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); } }