Class AbstractStringConfiguration

    • Constructor Detail

      • AbstractStringConfiguration

        public AbstractStringConfiguration()
    • Method Detail

      • findObject

        public <O> java.util.Optional<O> findObject​(java.lang.String key,
                                                    java.lang.Class<O> type)
                                             throws ConfigurationException
        Description copied from class: BaseConfiguration
        Retrieves a general configuration object that may not be present as the requested type, converting it as necessary. If the object is present but cannot be converted, a ConfigurationException will be thrown.
        Specified by:
        findObject in interface Configuration
        Overrides:
        findObject in class BaseConfiguration<java.lang.String>
        Type Parameters:
        O - The type of configuration object expected.
        Parameters:
        key - The configuration key.
        type - The type of object requested.
        Returns:
        The optional configuration value associated with the given key.
        Throws:
        ConfigurationException - if there is a configuration value stored in an invalid format.
      • dereferenceString

        @Nonnull
        protected java.lang.String dereferenceString​(@Nonnull
                                                     java.lang.String string)
        Evaluates and replaces any references in the given string.

        This method does not need to be called if the underlying configuration implementation already supports expression replacement.

        Parameters:
        string - The string for which expressions should be evaluated.
        Returns:
        A string with expressions evaluated, which may be the original string.
        Throws:
        java.lang.NullPointerException - if the given string is null.
        ConfigurationException - if an expression is not in the correct format, or if no value is associated with a key in an expression.
      • findConfigurationValue

        protected java.util.Optional<java.lang.String> findConfigurationValue​(@Nonnull
                                                                              java.lang.String key)
                                                                       throws ConfigurationException
        Tries to retrieves a general configuration value from the underlying storage. The key need not be normalized; it will be normalized as necessary.

        This method must not fall back to parent configuration; only local values must be returned.

        Overrides:
        findConfigurationValue in class BaseConfiguration<java.lang.String>
        Implementation Specification:
        This implementation normalizes the key, delegates to BaseConfiguration.findConfigurationValueImpl(String), and then dereferences the string using dereferenceString(String).
        Parameters:
        key - The configuration key, which may not be normalized.
        Returns:
        The optional configuration value associated with the given key.
        Throws:
        ConfigurationException - if there is a configuration value stored in an invalid format.
        See Also:
        dereferenceString(String)
      • findBoolean

        public java.util.Optional<java.lang.Boolean> findBoolean​(java.lang.String key)
                                                          throws ConfigurationException
        Retrieves a Boolean configuration value that may not be present.
        Implementation Specification:
        This implementation parses the value using Boolean.valueOf(String).
        Parameters:
        key - The configuration key.
        Returns:
        The optional configuration value associated with the given key.
        Throws:
        ConfigurationException - if there is a configuration value stored in an invalid format.
      • findDouble

        public java.util.OptionalDouble findDouble​(java.lang.String key)
                                            throws ConfigurationException
        Retrieves a floating point configuration value that may not be present.
        Implementation Specification:
        This implementation parses the value using Double.parseDouble(String).
        Parameters:
        key - The configuration key.
        Returns:
        The optional configuration value associated with the given key.
        Throws:
        ConfigurationException - if there is a configuration value stored in an invalid format.
      • findInt

        public java.util.OptionalInt findInt​(java.lang.String key)
                                      throws ConfigurationException
        Retrieves an integer configuration value that may not be present.
        Implementation Specification:
        This implementation parses the value using Integer.parseInt(String).
        Parameters:
        key - The configuration key.
        Returns:
        The optional configuration value associated with the given key.
        Throws:
        ConfigurationException - if there is a configuration value stored in an invalid format.
      • findLong

        public java.util.OptionalLong findLong​(java.lang.String key)
                                        throws ConfigurationException
        Retrieves a long integer configuration value that may not be present.
        Implementation Specification:
        This implementation parses the value using Long.parseLong(String).
        Parameters:
        key - The configuration key.
        Returns:
        The optional configuration value associated with the given key.
        Throws:
        ConfigurationException - if there is a configuration value stored in an invalid format.
      • findPath

        public java.util.Optional<java.nio.file.Path> findPath​(java.lang.String key)
                                                        throws ConfigurationException
        Retrieves a path configuration value that may not be present.

        The path will be resolved using Configuration.resolvePath(Path).

        Implementation Specification:
        This implementation parses the value using URI.create(String) and then resolves the path using Configuration.resolvePath(Path).
        Parameters:
        key - The configuration key.
        Returns:
        The optional configuration value associated with the given key.
        Throws:
        ConfigurationException - if there is a configuration value stored in an invalid format.
      • findString

        public java.util.Optional<java.lang.String> findString​(java.lang.String key)
                                                        throws ConfigurationException
        Retrieves a string configuration value that may not be present.

        TODO discuss dereferencing

        Implementation Specification:
        This implementation delegates to findConfigurationValue(String).
        Parameters:
        key - The configuration key.
        Returns:
        The optional configuration value associated with the given key.
        Throws:
        ConfigurationException - if there is a configuration value stored in an invalid format.
        See Also:
        Format.format(Object)
      • findUri

        public java.util.Optional<java.net.URI> findUri​(java.lang.String key)
                                                 throws ConfigurationException
        Retrieves a URI configuration value that may not be present.
        Implementation Specification:
        This implementation parses the value using URI.create(String).
        Parameters:
        key - The configuration key.
        Returns:
        The optional configuration value associated with the given key.
        Throws:
        ConfigurationException - if there is a configuration value stored in an invalid format.