Class EmptyConfiguration

  • All Implemented Interfaces:
    Configuration, Parameters

    public final class EmptyConfiguration
    extends AbstractConfiguration
    A configuration implementation that contains no definitions.

    This implementation will automatically delegate to the parent configuration, if any.

    Author:
    Garret Wilson
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.Boolean> getOptionalBoolean​(java.lang.String key)
      Retrieves a Boolean parameter that may not be present.
      java.util.Optional<java.lang.Double> getOptionalDouble​(java.lang.String key)
      Retrieves a floating point parameter that may not be present.
      java.util.Optional<java.lang.Integer> getOptionalInt​(java.lang.String key)
      Retrieves an integer parameter that may not be present.
      java.util.Optional<java.lang.Long> getOptionalLong​(java.lang.String key)
      Retrieves a long integer parameter that may not be present.
      <T> java.util.Optional<T> getOptionalParameter​(java.lang.String key)
      Retrieves a general parameter that may not be present.
      java.util.Optional<java.nio.file.Path> getOptionalPath​(java.lang.String key)
      Retrieves a path parameter that may not be present.
      java.util.Optional<java.lang.String> getOptionalString​(java.lang.String key)
      Retrieves a string parameter that may not be present.
      java.util.Optional<java.net.URI> getOptionalUri​(java.lang.String key)
      Retrieves a URI parameter that may not be present.
      boolean hasParameter​(java.lang.String key)
      Determines whether a parameter of some type exists for the given parameter key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EmptyConfiguration

        public EmptyConfiguration()
        No-argument constructor.
      • EmptyConfiguration

        public EmptyConfiguration​(@Nullable
                                  Configuration parentConfiguration)
        Optional parent configuration constructor.
        Parameters:
        parentConfiguration - The parent configuration to use for fallback lookup, or null if there is no parent configuration.
    • Method Detail

      • hasParameter

        public boolean hasParameter​(java.lang.String key)
                             throws ConfigurationException
        Description copied from interface: Configuration
        Determines whether a parameter of some type exists for the given parameter key.

        This method searches the parent configuration hierarchy if no parameter is available in this instance.

        Parameters:
        key - The parameter key.
        Returns:
        true if a parameter of type type could be retrieved from these parameters using the given key.
        Throws:
        ConfigurationException - if there is a parameter value stored in an invalid format.
      • getOptionalParameter

        public <T> java.util.Optional<T> getOptionalParameter​(java.lang.String key)
                                                       throws ConfigurationException
        Description copied from interface: Parameters
        Retrieves a general parameter that may not be present.
        Type Parameters:
        T - The type of parameter expected.
        Parameters:
        key - The parameter key.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        ConfigurationException - if there is a parameter value stored in an invalid format.
      • getOptionalDouble

        public java.util.Optional<java.lang.Double> getOptionalDouble​(java.lang.String key)
                                                               throws ConfigurationException
        Description copied from interface: Parameters
        Retrieves a floating point parameter that may not be present.
        Parameters:
        key - The parameter key.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        ConfigurationException - if there is a parameter value stored in an invalid format.
      • getOptionalBoolean

        public java.util.Optional<java.lang.Boolean> getOptionalBoolean​(java.lang.String key)
                                                                 throws ConfigurationException
        Description copied from interface: Parameters
        Retrieves a Boolean parameter that may not be present.
        Parameters:
        key - The parameter key.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        ConfigurationException - if there is a parameter value stored in an invalid format.
      • getOptionalInt

        public java.util.Optional<java.lang.Integer> getOptionalInt​(java.lang.String key)
                                                             throws ConfigurationException
        Description copied from interface: Parameters
        Retrieves an integer parameter that may not be present.
        Parameters:
        key - The parameter key.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        ConfigurationException - if there is a parameter value stored in an invalid format.
      • getOptionalLong

        public java.util.Optional<java.lang.Long> getOptionalLong​(java.lang.String key)
                                                           throws ConfigurationException
        Description copied from interface: Parameters
        Retrieves a long integer parameter that may not be present.

        The default implementation delegates to Parameters.getOptionalInt(String).

        Parameters:
        key - The parameter key.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        ConfigurationException - if there is a parameter value stored in an invalid format.
      • getOptionalString

        public java.util.Optional<java.lang.String> getOptionalString​(java.lang.String key)
                                                               throws ConfigurationException
        Description copied from interface: Parameters
        Retrieves a string parameter that may not be present.

        TODO discuss dereferencing

        Parameters:
        key - The parameter key.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        ConfigurationException - if there is a parameter value stored in an invalid format.
        See Also:
        Format.format(Object)
      • getOptionalPath

        public java.util.Optional<java.nio.file.Path> getOptionalPath​(java.lang.String key)
                                                               throws ConfigurationException
        Description copied from interface: Parameters
        Retrieves a path parameter that may not be present.

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

        Parameters:
        key - The parameter key.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        ConfigurationException - if there is a parameter value stored in an invalid format.
      • getOptionalUri

        public java.util.Optional<java.net.URI> getOptionalUri​(java.lang.String key)
                                                        throws ConfigurationException
        Description copied from interface: Parameters
        Retrieves a URI parameter that may not be present.
        Parameters:
        key - The parameter key.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        ConfigurationException - if there is a parameter value stored in an invalid format.