Class BaseConfiguration<T>

    • Constructor Detail

      • BaseConfiguration

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

      • normalizeKey

        protected java.lang.String normalizeKey​(@Nonnull
                                                java.lang.String key)
        Normalizes a requested key if required by this implementation.

        The default implementation returns the key unmodified after checking for null.

        Parameters:
        key - The parameter key.
        Returns:
        The requested parameter key, modified as needed for lookup in this implementation.
      • hasParameter

        public boolean hasParameter​(@Nonnull
                                    java.lang.String key)
                             throws ConfigurationException
        Determines whether a parameter of some type exists for the given parameter key.

        This implementation normalizes the key and delegates to hasParameterImpl(String). Most subclasses should not override this method, and instead override hasParameterImpl(String).

        Parameters:
        key - The parameter key.
        Returns:
        true if a parameter of type type could be retrieved from these parameters using the given key.
        Throws:
        java.lang.NullPointerException - if the given key is null.
        java.lang.SecurityException - If a security manager exists and it doesn't allow access to the specified parameter.
        ConfigurationException - if there is a parameter value stored in an invalid format.
      • hasParameterImpl

        protected boolean hasParameterImpl​(@Nonnull
                                           java.lang.String key)
                                    throws ConfigurationException
        Determines whether a parameter is present in the underlying storage.

        The given parameter key is assumed to already be normalized, and should not be modified.

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

        The default implementation delegates to findParameterImpl(String).

        Parameters:
        key - The normalized parameter key.
        Returns:
        true if a parameter of type type could be retrieved from these parameters using the given key.
        Throws:
        java.lang.NullPointerException - if the given key is null.
        java.lang.SecurityException - If a security manager exists and it doesn't allow access to the specified parameter.
        ConfigurationException - if there is a parameter value stored in an invalid format.
      • getOptionalParameter

        public <P> java.util.Optional<P> getOptionalParameter​(java.lang.String key)
                                                       throws ConfigurationException
        Retrieves a general parameter that may not be present.

        This implementation delegates to findParameter(String).

        Type Parameters:
        P - 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.
      • findParameter

        protected java.util.Optional<T> findParameter​(@Nonnull
                                                      java.lang.String key)
                                               throws ConfigurationException
        Tries to retrieves a general parameter 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 strings must be returned.

        This is an internal API call that should be used by child classes to funnel requests to the underlying storage. Normally child classes will not override this method, but override findParameterImpl(String) instead.

        Parameters:
        key - The parameter key, which may not be normalized.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        java.lang.NullPointerException - if the given key is null.
        java.lang.SecurityException - If a security manager exists and it doesn't allow access to the specified parameter.
        ConfigurationException - if there is a parameter value stored in an invalid format.
        See Also:
        normalizeKey(String)
      • findParameterImpl

        protected abstract java.util.Optional<T> findParameterImpl​(@Nonnull
                                                                   java.lang.String key)
                                                            throws ConfigurationException
        Implementation to retrieves a general parameter that may not be present from the underlying storage.

        The given parameter key is assumed to already be normalized, and should not be modified.

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

        Parameters:
        key - The normalized parameter key.
        Returns:
        The optional value of the parameter associated with the given key.
        Throws:
        java.lang.NullPointerException - if the given key is null.
        java.lang.SecurityException - If a security manager exists and it doesn't allow access to the specified parameter.
        ConfigurationException - if there is a parameter value stored in an invalid format.