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