Class OverrideConfigSupplier<Message extends PMessage<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 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 class java.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.