- java.lang.Object
-
- io.helidon.config.AbstractSourceBuilder<B,U>
-
- io.helidon.config.AbstractConfigSourceBuilder<FileConfigSource.Builder,Path>
-
- io.helidon.config.FileConfigSource.Builder
-
- All Implemented Interfaces:
Builder<FileConfigSource>
,ParsableSource.Builder<FileConfigSource.Builder>
,PollableSource.Builder<FileConfigSource.Builder>
,Source.Builder<FileConfigSource.Builder>
,WatchableSource.Builder<FileConfigSource.Builder,Path>
,Supplier<FileConfigSource>
- Enclosing class:
- FileConfigSource
public static final class FileConfigSource.Builder extends AbstractConfigSourceBuilder<FileConfigSource.Builder,Path> implements PollableSource.Builder<FileConfigSource.Builder>, WatchableSource.Builder<FileConfigSource.Builder,Path>, ParsableSource.Builder<FileConfigSource.Builder>, Builder<FileConfigSource>
File ConfigSource Builder.It allows to configure following properties:
path
- configuration file path;optional
- is existence of configuration resource optional, or mandatory (by default)?media-type
- configuration content media type to be used to look for appropriateConfigParser
;parser
- or directly setConfigParser
instance to be used to parse the source;
If
media-type
not set it tries to guess it from file extension.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileConfigSource
build()
Builds new instance of File ConfigSource.FileConfigSource.Builder
changeWatcher(ChangeWatcher<Path> changeWatcher)
Configure a change watcher.FileConfigSource.Builder
config(Config metaConfig)
Configure builder from meta configuration.FileConfigSource.Builder
mediaType(String mediaType)
Media type if this is aParsableSource
and explicit media type is configured.FileConfigSource.Builder
parser(ConfigParser parser)
A parser if this is aParsableSource
and explicit parser is configured.FileConfigSource.Builder
path(Path path)
Configure the path to read configuration from (mandatory).FileConfigSource.Builder
pollingStrategy(PollingStrategy pollingStrategy)
Configure a polling strategy.-
Methods inherited from class io.helidon.config.AbstractConfigSourceBuilder
mediaTypeMapping, parserMapping
-
Methods inherited from class io.helidon.config.AbstractSourceBuilder
optional, retryPolicy
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.config.spi.PollableSource.Builder
pollingStrategy
-
Methods inherited from interface io.helidon.config.spi.Source.Builder
optional, optional, retryPolicy
-
-
-
-
Method Detail
-
path
public FileConfigSource.Builder path(Path path)
Configure the path to read configuration from (mandatory).- Parameters:
path
- path of a file to use- Returns:
- updated builder instance
-
config
public FileConfigSource.Builder config(Config metaConfig)
Configure builder from meta configuration.The following configuration options are supported:
Optional configuration parameters key default value description optional false
Configure to true
if this source should not fail configuration setup when underlying data is missing.polling-strategy No polling strategy is added by default Meta configuration of a polling strategy to be used with this source, add configuration to properties
sub node.change-watcher No change watcher is added by default Meta configuration of a change watcher to be used with this source, add configuration to properties
sub node.retry-policy No retry policy is added by default Meta configuration of a retry policy to be used to load this source, add configuration to properties
sub node.Media type and type mapping media-type Media type from loaded data is used by default for parsable config sources Explicit media type to use, such as when a file has invalid suffix, or when we need to explicitly mark the media type. media-type-mapping No media type mapping is done by default A mapping of key to a media type, allowing us to have a key that contains a sub-tree (e.g. a key that contains json data) - when we configure a mapping of the key to application/json
, the data would be expanded into config as a proper tree structurepath
- path to the file containing the configuration
- Overrides:
config
in classAbstractConfigSourceBuilder<FileConfigSource.Builder,Path>
- Parameters:
metaConfig
- configuration properties used to configure a builder instance.- Returns:
- modified builder instance
-
parser
public FileConfigSource.Builder parser(ConfigParser parser)
Description copied from class:AbstractConfigSourceBuilder
A parser if this is aParsableSource
and explicit parser is configured.- Specified by:
parser
in interfaceParsableSource.Builder<FileConfigSource.Builder>
- Overrides:
parser
in classAbstractConfigSourceBuilder<FileConfigSource.Builder,Path>
- Parameters:
parser
- parser configured for this source- Returns:
- updated builder instance
-
mediaType
public FileConfigSource.Builder mediaType(String mediaType)
Description copied from class:AbstractConfigSourceBuilder
Media type if this is aParsableSource
and explicit media type is configured.- Specified by:
mediaType
in interfaceParsableSource.Builder<FileConfigSource.Builder>
- Overrides:
mediaType
in classAbstractConfigSourceBuilder<FileConfigSource.Builder,Path>
- Parameters:
mediaType
- media type configured for this source- Returns:
- updated builder instance
-
changeWatcher
public FileConfigSource.Builder changeWatcher(ChangeWatcher<Path> changeWatcher)
Description copied from class:AbstractSourceBuilder
Configure a change watcher. This method must be exposed by builders of sources that change watching (WatchableSource
). The type of the change watcher must match the type of the target of this source.- Specified by:
changeWatcher
in interfaceWatchableSource.Builder<FileConfigSource.Builder,Path>
- Overrides:
changeWatcher
in classAbstractSourceBuilder<FileConfigSource.Builder,Path>
- Parameters:
changeWatcher
- change watcher to use, such asFileSystemWatcher
- Returns:
- updated builder instance
-
pollingStrategy
public FileConfigSource.Builder pollingStrategy(PollingStrategy pollingStrategy)
Description copied from class:AbstractSourceBuilder
Configure a polling strategy. This method must be exposed by builders of sources that support polling. If you see this method as being protected in your builder, the source has removed support for polling, such asClasspathConfigSource
.- Specified by:
pollingStrategy
in interfacePollableSource.Builder<FileConfigSource.Builder>
- Overrides:
pollingStrategy
in classAbstractSourceBuilder<FileConfigSource.Builder,Path>
- Parameters:
pollingStrategy
- polling strategy to use- Returns:
- updated builder instance
-
build
public FileConfigSource build()
Builds new instance of File ConfigSource.If
media-type
not set it tries to guess it from file extension.- Specified by:
build
in interfaceBuilder<FileConfigSource>
- Returns:
- new instance of File ConfigSource.
-
-