Class ResourcesConfigurationManager.Builder

  • Enclosing class:
    ResourcesConfigurationManager

    public static class ResourcesConfigurationManager.Builder
    extends java.lang.Object
    Builder for the manager.

    By default the configuration will be required. The file formats installed from their providers will be used if none are specified.

    Author:
    Garret Wilson
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • parentConfiguration

        public ResourcesConfigurationManager.Builder parentConfiguration​(@Nonnull
                                                                         io.confound.config.Configuration parentConfiguration)
        Sets the parent configuration to use for fallback lookup.
        Parameters:
        parentConfiguration - The parent, fallback configuration.
        Returns:
        This builder.
      • required

        public ResourcesConfigurationManager.Builder required​(boolean required)
        Sets whether the configuration file is required to be discovered.
        Parameters:
        required - true if a configuration is required and the manager will always return a configuration and throw an exception if one cannot be determined.
        Returns:
        This builder.
      • contextClass

        public ResourcesConfigurationManager.Builder contextClass​(@Nonnull
                                                                  java.lang.Class<?> contextClass)
        Sets the context class to use for a class loader if none is specified separately, and for determining a base path if none is specified separately.
        Parameters:
        contextClass - The class providing the resource context for loading.
        Returns:
        This builder.
        Throws:
        java.lang.NullPointerException - if the context class is null.
      • classLoader

        public ResourcesConfigurationManager.Builder classLoader​(@Nonnull
                                                                 java.lang.ClassLoader classLoader)
        Sets the explicit class loader for loading resources.
        Parameters:
        classLoader - The class loader to use for loading a configuration resource.
        Returns:
        This builder.
        Throws:
        java.lang.NullPointerException - if the class loader is null.
      • resourcePath

        public ResourcesConfigurationManager.Builder resourcePath​(@Nonnull
                                                                  java.lang.String resourcePath)
        Uses a complete path to a configuration resource relative to the classpath.

        Overrides any resource base filename or resource filename.

        Parameters:
        resourcePath - The complete resource path such as com/example/foo.bar, relative to the classpath, for loading a configuration file from class resources.
        Returns:
        This builder.
        Throws:
        java.lang.NullPointerException - if the resource path is null.
      • resourceName

        public ResourcesConfigurationManager.Builder resourceName​(@Nonnull
                                                                  java.lang.String resourceName)
        Uses a complete resource filename. A context class must be specified separately.

        Overrides any resource path or resource base filename.

        Parameters:
        resourceName - The resource filename, such as foo.bar for loading a configuration resource relative to the given class.
        Returns:
        This builder.
        Throws:
        java.lang.NullPointerException - if the resource filename is null.
      • resourceBaseName

        public ResourcesConfigurationManager.Builder resourceBaseName​(@Nonnull
                                                                      java.lang.String resourceBaseName)
        Uses a resource base filename.

        Overrides any resource path or resource base filename.

        Parameters:
        resourceBaseName - The base filename, such as base, to locate resources with extensions, such as base.foo, supported by installed configuration file formats.
        Returns:
        This builder.
        Throws:
        java.lang.NullPointerException - if the resource base filename is null.
      • build

        public ResourcesConfigurationManager build()
        Builds a configuration manager.
        Returns:
        A new manager built to these specifications.
        Throws:
        java.lang.IllegalStateException - if no class loader could be determined and/or no path information has been specified.
      • buildConfiguration

        public io.confound.config.ManagedConfiguration buildConfiguration()
        Builds a manage configured, managed by new resources configuration manager, and using the specified parent configuration, if any.
        Returns:
        A new configuration managed by a manager built to these specifications.
        Throws:
        java.lang.IllegalStateException - if no class loader could be determined and/or no path information has been specified.
        See Also:
        parentConfiguration(Configuration)