Class FileSystemConfigurationManager.Builder

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

public static class FileSystemConfigurationManager.Builder extends Object
Builder for the manager.

By default the configuration will be optional. 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 FileSystemConfigurationManager.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 FileSystemConfigurationManager.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.
    • candidatePaths

      public FileSystemConfigurationManager.Builder candidatePaths(@Nonnull Path... candidatePaths)
      Uses a series of paths as candidate paths for configuration file discovery.

      The first configuration file with a supported format is used.

      Parameters:
      candidatePaths - The potential paths at which to find the configuration file.
      Returns:
      This builder.
      Throws:
      NullPointerException - if one of the candidate paths is null.
      IllegalArgumentException - if no paths are given, or if one of the given paths has no filename.
    • baseFilename

      public FileSystemConfigurationManager.Builder baseFilename(@Nonnull Path directory, @Nonnull String baseFilename)
      Uses a base path and a base filename.
      Parameters:
      directory - The source directory for configuration file discovery.
      baseFilename - The base filename, such as base, to return files with any extension, such as base.foo and base.foo.bar, or no extension at all.
      Returns:
      This builder.
      Throws:
      NullPointerException - if the directory and/or base filename is null.
      See Also:
      • Filenames.getBaseFilenamePattern(String)
    • filenameGlob

      public FileSystemConfigurationManager.Builder filenameGlob(@Nonnull Path directory, @Nonnull String filenameGlob)
      Uses a base path and a filename glob to discover the configuration file.

      Only a single directory level is searched, regardless of the glob.

      Parameters:
      directory - The source directory for configuration file discovery.
      filenameGlob - The glob for matching files in the directory, such as foo?.{properties,xml} which would match both foot.xml and food.properties.
      Returns:
      This builder.
      Throws:
      NullPointerException - if the directory and/or filename glob is null.
    • filenamePattern

      public FileSystemConfigurationManager.Builder filenamePattern(@Nonnull Path directory, @Nonnull Pattern filenamePattern)
      Uses a base path and a filename pattern to discover the configuration file.
      Parameters:
      directory - The source directory for configuration file discovery.
      filenamePattern - The regular expression pattern for matching files in the directory.
      Returns:
      This builder.
      Throws:
      NullPointerException - if the directory and/or filename pattern is null.
    • build

      Builds a configuration manager.
      Returns:
      A new manager built to these specifications.
      Throws:
      IllegalStateException - if no candidate path(s) have been specified.
    • buildConfiguration

      public io.confound.config.ManagedConfiguration buildConfiguration()
      Builds a manage configured, managed by new file system 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 candidate path(s) have been specified.
      See Also: