Class AbstractObjectConfiguration

  • All Implemented Interfaces:
    Configuration
    Direct Known Subclasses:
    ObjectMapConfiguration

    public abstract class AbstractObjectConfiguration
    extends BaseConfiguration<java.lang.Object>
    Abstract configuration implementation for which the underlying storage is based on general objects.
    Author:
    Garret Wilson
    Implementation Specification:
    The current implementation supports conversion between number types; otherwise this class throws a ConfigurationException if the requested object is not of the requested type.
    • Constructor Detail

      • AbstractObjectConfiguration

        public AbstractObjectConfiguration()
    • Method Detail

      • convertValue

        protected <O> java.util.Optional<O> convertValue​(@Nonnull
                                                         java.util.Optional<java.lang.Object> value,
                                                         @Nonnull
                                                         java.lang.Class<O> convertClass)
                                                  throws ConfigurationException
        Converts a configuration value from its actual type in the underlying storage to the requested type.
        Overrides:
        convertValue in class BaseConfiguration<java.lang.Object>
        Implementation Specification:
        The current implementation supports conversion between number types; otherwise this implementation merely checked to see if the value can be cast to the requested type.
        Type Parameters:
        O - The requested conversion type.
        Parameters:
        value - The value to convert.
        convertClass - The class indicating the requested conversion type.
        Returns:
        The value converted to the requested type.
        Throws:
        ConfigurationException - if the value is present and cannot be converted to the requested type.
      • 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 converts the value using convertValue(Optional, Class).
        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 converts the value using convertValue(Optional, Class).
        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 converts the value using convertValue(Optional, Class).
        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 converts the value using convertValue(Optional, Class).
        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 final 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 converts the value using convertValue(Optional, Class).
        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 converts the value using convertValue(Optional, Class).
        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.