Class FileSystemConfigurationManager.Builder

  • Enclosing class:
    FileSystemConfigurationManager

    public static class FileSystemConfigurationManager.Builder
    extends java.lang.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 Detail

      • Builder

        public Builder()
    • Method Detail

      • 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.
      • 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
                                                                     java.nio.file.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:
        java.lang.NullPointerException - if one of the candidate paths is null.
        java.lang.IllegalArgumentException - if no paths are given, or if one of the given paths has no filename.
      • baseFilename

        public FileSystemConfigurationManager.Builder baseFilename​(@Nonnull
                                                                   java.nio.file.Path directory,
                                                                   @Nonnull
                                                                   java.lang.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:
        java.lang.NullPointerException - if the directory and/or base filename is null.
        See Also:
        Filenames.getBaseFilenamePattern(String)
      • filenameGlob

        public FileSystemConfigurationManager.Builder filenameGlob​(@Nonnull
                                                                   java.nio.file.Path directory,
                                                                   @Nonnull
                                                                   java.lang.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:
        java.lang.NullPointerException - if the directory and/or filename glob is null.
      • filenamePattern

        public FileSystemConfigurationManager.Builder filenamePattern​(@Nonnull
                                                                      java.nio.file.Path directory,
                                                                      @Nonnull
                                                                      java.util.regex.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:
        java.lang.NullPointerException - if the directory and/or filename pattern is null.
      • build

        public FileSystemConfigurationManager build()
        Builds a configuration manager.
        Returns:
        A new manager built to these specifications.
        Throws:
        java.lang.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:
        java.lang.IllegalStateException - if no candidate path(s) have been specified.
        See Also:
        parentConfiguration(Configuration)