Package io.confound.config.file
Class FileSystemConfigurationManager.Builder
- java.lang.Object
-
- io.confound.config.file.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 Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileSystemConfigurationManager.Builder
baseFilename(java.nio.file.Path directory, java.lang.String baseFilename)
Uses a base path and a base filename.FileSystemConfigurationManager
build()
Builds a configuration manager.io.confound.config.ManagedConfiguration
buildConfiguration()
Builds a manage configured, managed by new file system configuration manager, and using the specified parent configuration, if any.FileSystemConfigurationManager.Builder
candidatePaths(java.nio.file.Path... candidatePaths)
Uses a series of paths as candidate paths for configuration file discovery.FileSystemConfigurationManager.Builder
fileFormat(ConfigurationFileFormat fileFormat)
Sets a single file format to be supported by the configuration manager.FileSystemConfigurationManager.Builder
fileFormats(java.lang.Iterable<ConfigurationFileFormat> fileFormats)
Sets the file formats to be supported by the configuration manager.FileSystemConfigurationManager.Builder
filenameGlob(java.nio.file.Path directory, java.lang.String filenameGlob)
Uses a base path and a filename glob to discover the configuration file.FileSystemConfigurationManager.Builder
filenamePattern(java.nio.file.Path directory, java.util.regex.Pattern filenamePattern)
Uses a base path and a filename pattern to discover the configuration file.FileSystemConfigurationManager.Builder
parentConfiguration(io.confound.config.Configuration parentConfiguration)
Sets the parent configuration to use for fallback lookup.FileSystemConfigurationManager.Builder
required(boolean required)
Sets whether the configuration file is required to be discovered.
-
-
-
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.
-
fileFormat
public FileSystemConfigurationManager.Builder fileFormat(@Nonnull ConfigurationFileFormat fileFormat)
Sets a single file format to be supported by the configuration manager.- Parameters:
fileFormat
- The file format to support.- Returns:
- This builder.
-
fileFormats
public FileSystemConfigurationManager.Builder fileFormats(@Nonnull java.lang.Iterable<ConfigurationFileFormat> 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 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 isnull
.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 asbase
, to return files with any extension, such asbase.foo
andbase.foo.bar
, or no extension at all.- Returns:
- This builder.
- Throws:
java.lang.NullPointerException
- if the directory and/or base filename isnull
.- 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 asfoo?.{properties,xml}
which would match bothfoot.xml
andfood.properties
.- Returns:
- This builder.
- Throws:
java.lang.NullPointerException
- if the directory and/or filename glob isnull
.
-
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 isnull
.
-
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)
-
-