Package io.confound.config.file
Class ResourcesConfigurationManager.Builder
java.lang.Object
io.confound.config.file.ResourcesConfigurationManager.Builder
- Enclosing class:
- ResourcesConfigurationManager
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a configuration manager.io.confound.config.ManagedConfiguration
Builds a manage configured, managed by new resources configuration manager, and using the specified parent configuration, if any.classLoader
(ClassLoader classLoader) Sets the explicit class loader for loading resources.contextClass
(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.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.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.resourceBaseName
(String resourceBaseName) Uses a resource base filename.resourceName
(String resourceName) Uses a complete resource filename.resourcePath
(String resourcePath) Uses a complete path to a configuration resource relative to the classpath.
-
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
public ResourcesConfigurationManager.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 ResourcesConfigurationManager.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.
-
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 isnull
.
-
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 isnull
.
-
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 ascom/example/foo.bar
, relative to the classpath, for loading a configuration file from class resources.- Returns:
- This builder.
- Throws:
NullPointerException
- if the resource path isnull
.
-
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 asfoo.bar
for loading a configuration resource relative to the given class.- Returns:
- This builder.
- Throws:
NullPointerException
- if the resource filename isnull
.
-
resourceBaseName
Uses a resource base filename.Overrides any resource path or resource base filename.
- Parameters:
resourceBaseName
- The base filename, such asbase
, to locate resources with extensions, such asbase.foo
, supported by installed configuration file formats.- Returns:
- This builder.
- Throws:
NullPointerException
- if the resource base filename isnull
.
-
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:
-