Class ConfigOption<T>

  • Type Parameters:
    T - The type of value associated with the configuration option.

    @PublicEvolving
    public class ConfigOption<T>
    extends Object
    A ConfigOption describes a configuration parameter. It encapsulates the configuration key, deprecated older versions of the key, and an optional default value for the configuration parameter.

    ConfigOptions are built via the ConfigOptions class. Once created, a config option is immutable.

    • Method Detail

      • withFallbackKeys

        public ConfigOption<T> withFallbackKeys​(String... fallbackKeys)
        Creates a new config option, using this option's key and default value, and adding the given fallback keys.

        When obtaining a value from the configuration via 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.

        Parameters:
        fallbackKeys - The fallback keys, in the order in which they should be checked.
        Returns:
        A new config options, with the given fallback keys.
      • withDeprecatedKeys

        public ConfigOption<T> withDeprecatedKeys​(String... deprecatedKeys)
        Creates a new config option, using this option's key and default value, and adding the given deprecated keys.

        When obtaining a value from the configuration via 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.

        Parameters:
        deprecatedKeys - The deprecated keys, in the order in which they should be checked.
        Returns:
        A new config options, with the given deprecated keys.
      • withDescription

        public ConfigOption<T> withDescription​(String description)
        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 documentation.
        Parameters:
        description - The description for this option.
        Returns:
        A new config option, with given description.
      • withDescription

        public ConfigOption<T> withDescription​(Description description)
        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 documentation.
        Parameters:
        description - The description for this option.
        Returns:
        A new config option, with given description.
      • key

        public String key()
        Gets the configuration key.
        Returns:
        The configuration key
      • hasDefaultValue

        public boolean hasDefaultValue()
        Checks if this option has a default value.
        Returns:
        True if it has a default value, false if not.
      • defaultValue

        public T defaultValue()
        Returns the default value, or null, if there is no default value.
        Returns:
        The default value, or null.
      • hasFallbackKeys

        public boolean hasFallbackKeys()
        Checks whether this option has fallback keys.
        Returns:
        True if the option has fallback keys, false if not.
      • fallbackKeys

        public Iterable<FallbackKey> fallbackKeys()
        Gets the fallback keys, in the order to be checked.
        Returns:
        The option's fallback keys.
      • description

        public Description description()
        Returns the description of this option.
        Returns:
        The option's description.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object