Package io.confound.config.file
Class ResourcesConfigurationManager.Builder
- java.lang.Object
-
- io.confound.config.file.ResourcesConfigurationManager.Builder
-
- Enclosing class:
- ResourcesConfigurationManager
public static class ResourcesConfigurationManager.Builder extends java.lang.ObjectBuilder 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 Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourcesConfigurationManagerbuild()Builds a configuration manager.io.confound.config.ManagedConfigurationbuildConfiguration()Builds a manage configured, managed by new resources configuration manager, and using the specified parent configuration, if any.ResourcesConfigurationManager.BuilderclassLoader(java.lang.ClassLoader classLoader)Sets the explicit class loader for loading resources.ResourcesConfigurationManager.BuildercontextClass(java.lang.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.ResourcesConfigurationManager.BuilderfileFormat(ConfigurationFileFormat fileFormat)Sets a single file format to be supported by the configuration manager.ResourcesConfigurationManager.BuilderfileFormats(java.lang.Iterable<ConfigurationFileFormat> fileFormats)Sets the file formats to be supported by the configuration manager.ResourcesConfigurationManager.BuilderparentConfiguration(io.confound.config.Configuration parentConfiguration)Sets the parent configuration to use for fallback lookup.ResourcesConfigurationManager.Builderrequired(boolean required)Sets whether the configuration file is required to be discovered.ResourcesConfigurationManager.BuilderresourceBaseName(java.lang.String resourceBaseName)Uses a resource base filename.ResourcesConfigurationManager.BuilderresourceName(java.lang.String resourceName)Uses a complete resource filename.ResourcesConfigurationManager.BuilderresourcePath(java.lang.String resourcePath)Uses a complete path to a configuration resource relative to the classpath.
-
-
-
Method Detail
-
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 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 ResourcesConfigurationManager.Builder required(boolean required)
Sets whether the configuration file is required to be discovered.- Parameters:
required-trueif 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
public ResourcesConfigurationManager.Builder contextClass(@Nonnull java.lang.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.- Parameters:
contextClass- The class providing the resource context for loading.- Returns:
- This builder.
- Throws:
java.lang.NullPointerException- if the context class isnull.
-
classLoader
public ResourcesConfigurationManager.Builder classLoader(@Nonnull java.lang.ClassLoader 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:
java.lang.NullPointerException- if the class loader isnull.
-
resourcePath
public ResourcesConfigurationManager.Builder resourcePath(@Nonnull java.lang.String 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:
java.lang.NullPointerException- if the resource path isnull.
-
resourceName
public ResourcesConfigurationManager.Builder resourceName(@Nonnull java.lang.String 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.barfor loading a configuration resource relative to the given class.- Returns:
- This builder.
- Throws:
java.lang.NullPointerException- if the resource filename isnull.
-
resourceBaseName
public ResourcesConfigurationManager.Builder resourceBaseName(@Nonnull java.lang.String 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:
java.lang.NullPointerException- if the resource base filename isnull.
-
build
public ResourcesConfigurationManager build()
Builds a configuration manager.- Returns:
- A new manager built to these specifications.
- Throws:
java.lang.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:
java.lang.IllegalStateException- if no class loader could be determined and/or no path information has been specified.- See Also:
parentConfiguration(Configuration)
-
-