Package net.morimekta.providence.config
Class ProvidenceConfig
- java.lang.Object
-
- net.morimekta.providence.config.ProvidenceConfig
-
- All Implemented Interfaces:
ConfigResolver
public class ProvidenceConfig extends java.lang.Object implements ConfigResolver
Providence config loader. This loads providence configs.
-
-
Constructor Summary
Constructors Constructor Description ProvidenceConfig(net.morimekta.providence.util.TypeRegistry registry)
Make a non-strict config instance.ProvidenceConfig(net.morimekta.providence.util.TypeRegistry registry, net.morimekta.util.FileWatcher watcher, boolean strict)
Make a config instance.ProvidenceConfig(net.morimekta.providence.util.TypeRegistry registry, net.morimekta.util.FileWatcher watcher, boolean strict, java.time.Clock clock)
Make a config instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
MgetConfig(java.io.File configFile)
Get config for the given file.<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
MgetConfig(java.io.File configFile, M parent)
Get config for the given with parent.<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
ConfigSupplier<M,F>resolveConfig(java.io.File configFile, ConfigSupplier<M,F> parentConfig)
Resolve a config file like on config file includes.-
Methods inherited from interface net.morimekta.providence.config.ConfigResolver
resolveConfig
-
-
-
-
Constructor Detail
-
ProvidenceConfig
public ProvidenceConfig(net.morimekta.providence.util.TypeRegistry registry)
Make a non-strict config instance.- Parameters:
registry
- The type registry used to find message and enum types.
-
ProvidenceConfig
public ProvidenceConfig(@Nonnull net.morimekta.providence.util.TypeRegistry registry, @Nullable net.morimekta.util.FileWatcher watcher, boolean strict)
Make a config instance.- Parameters:
registry
- The type registry used to find message and enum types.watcher
- File watcher used to detect config file updates.strict
- If the config should be parsed strictly.
-
ProvidenceConfig
public ProvidenceConfig(@Nonnull net.morimekta.providence.util.TypeRegistry registry, @Nullable net.morimekta.util.FileWatcher watcher, boolean strict, @Nonnull java.time.Clock clock)
Make a config instance.- Parameters:
registry
- The type registry used to find message and enum types.watcher
- File watcher used to detect config file updates.strict
- If the config should be parsed strictly.clock
- The clock to use in timing config loads.
-
-
Method Detail
-
resolveConfig
@Nonnull public <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField> ConfigSupplier<M,F> resolveConfig(@Nonnull java.io.File configFile, @Nullable ConfigSupplier<M,F> parentConfig) throws ProvidenceConfigException
Description copied from interface:ConfigResolver
Resolve a config file like on config file includes.- Specified by:
resolveConfig
in interfaceConfigResolver
- Type Parameters:
M
- The message type.F
- The message field type.- Parameters:
configFile
- The file to resolve.parentConfig
- The parent config supplier if any.- Returns:
- The resolved config.
- Throws:
ProvidenceConfigException
- If parsing of config failed.
-
getConfig
@Nonnull public <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField> M getConfig(@Nonnull java.io.File configFile) throws ProvidenceConfigException
Get config for the given file.- Type Parameters:
M
- The config message type.F
- The config message field type.- Parameters:
configFile
- The file to read config for.- Returns:
- The config message.
- Throws:
ProvidenceConfigException
- On config load failure.
-
getConfig
@Nonnull public <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField> M getConfig(@Nonnull java.io.File configFile, @Nonnull M parent) throws ProvidenceConfigException
Get config for the given with parent.- Type Parameters:
M
- The config message type.F
- The config message field type.- Parameters:
configFile
- The file to read config for.parent
- The designated parent config.- Returns:
- The config message.
- Throws:
ProvidenceConfigException
- On config load failure.
-
-