Class ResourcesConfigurationManager.Builder

java.lang.Object
io.confound.config.file.ResourcesConfigurationManager.Builder
Enclosing class:
ResourcesConfigurationManager

public static class ResourcesConfigurationManager.Builder extends 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 Details

    • Builder

      public Builder()
  • Method Details

    • 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.
    • fileFormat

      Sets a single file format to be supported by the configuration manager.
      Parameters:
      fileFormat - The file format to support.
      Returns:
      This builder.
    • fileFormats

      Sets the file formats to be supported by the configuration manager.
      Parameters:
      fileFormats - The file formats to support.
      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 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:
      NullPointerException - if the context class is null.
    • 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:
      NullPointerException - if the class loader is null.
    • resourcePath

      public ResourcesConfigurationManager.Builder resourcePath(@Nonnull 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:
      NullPointerException - if the resource path is null.
    • resourceName

      public ResourcesConfigurationManager.Builder resourceName(@Nonnull 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:
      NullPointerException - if the resource filename is null.
    • resourceBaseName

      public ResourcesConfigurationManager.Builder resourceBaseName(@Nonnull 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:
      NullPointerException - if the resource base filename is null.
    • build

      Builds a configuration manager.
      Returns:
      A new manager built to these specifications.
      Throws:
      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:
      IllegalStateException - if no class loader could be determined and/or no path information has been specified.
      See Also: