Class OverrideConfigSupplier<Message extends PMessage<Message>>
- java.lang.Object
-
- net.morimekta.providence.config.impl.UpdatingConfigSupplier<Message>
-
- net.morimekta.providence.config.impl.OverrideConfigSupplier<Message>
-
- All Implemented Interfaces:
java.util.function.Supplier<Message>
,ConfigSupplier<Message>
public class OverrideConfigSupplier<Message extends PMessage<Message>> extends UpdatingConfigSupplier<Message>
A supplier of a providence message config based on a parent config (supplier) and a map of value overrides. Handy for use with argument parsers overrides, system property overrides or similar.Supplier<Service> supplier = new OverrideConfigSupplier<>( baseServiceConfig, ImmutableMap.of( "db.username", "root", "jdbc.driver", "com.oracle.jdbc.Driver" ));
-
-
Constructor Summary
Constructors Constructor Description OverrideConfigSupplier(java.time.Clock clock, ConfigSupplier<Message> parent, java.util.Map<java.lang.String,java.lang.String> overrides, boolean strict)
Create a config that wraps a providence message instance.OverrideConfigSupplier(ConfigSupplier<Message> parent, java.util.Map<java.lang.String,java.lang.String> overrides)
Create a config that wraps a providence message instance.OverrideConfigSupplier(ConfigSupplier<Message> parent, java.util.Map<java.lang.String,java.lang.String> overrides, boolean strict)
Create a config that wraps a providence message instance.OverrideConfigSupplier(ConfigSupplier<Message> parent, java.util.Properties overrides)
Create a config that wraps a providence message instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getName()
Get a simple descriptive name for this config supplier.java.lang.String
toString()
-
Methods inherited from class net.morimekta.providence.config.impl.UpdatingConfigSupplier
addListener, configTimestamp, get, getClock, reference, removeListener, set
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.morimekta.providence.config.ConfigSupplier
override, override, snapshot
-
-
-
-
Constructor Detail
-
OverrideConfigSupplier
public OverrideConfigSupplier(@Nonnull ConfigSupplier<Message> parent, @Nonnull java.util.Properties overrides) throws ConfigException
Create a config that wraps a providence message instance. This message will be exposed without any key prefix. Note that reading from properties are never strict.- Parameters:
parent
- The parent message to override values of.overrides
- The message override values.- Throws:
ConfigException
- If message overriding failed
-
OverrideConfigSupplier
public OverrideConfigSupplier(@Nonnull ConfigSupplier<Message> parent, @Nonnull java.util.Map<java.lang.String,java.lang.String> overrides) throws ConfigException
Create a config that wraps a providence message instance. This message will be exposed without any key prefix.- Parameters:
parent
- The parent message to override values of.overrides
- The message override values.- Throws:
ConfigException
- If message overriding failed
-
OverrideConfigSupplier
public OverrideConfigSupplier(@Nonnull ConfigSupplier<Message> parent, @Nonnull java.util.Map<java.lang.String,java.lang.String> overrides, boolean strict) throws ConfigException
Create a config that wraps a providence message instance. This message will be exposed without any key prefix.- Parameters:
parent
- The parent message to override values of.overrides
- The message override values.strict
- If config should be read strictly.- Throws:
ConfigException
- If message overriding failed
-
OverrideConfigSupplier
public OverrideConfigSupplier(@Nonnull java.time.Clock clock, @Nonnull ConfigSupplier<Message> parent, @Nonnull java.util.Map<java.lang.String,java.lang.String> overrides, boolean strict) throws ConfigException
Create a config that wraps a providence message instance. This message will be exposed without any key prefix.- Parameters:
clock
- Clock used to time the updates.parent
- The parent message to override values of.overrides
- The message override values.strict
- If config should be read strictly.- Throws:
ConfigException
- If message overriding failed
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getName
public java.lang.String getName()
Description copied from interface:ConfigSupplier
Get a simple descriptive name for this config supplier.- Returns:
- The supplier name.
-
-