Interface ConfigurationSource<A extends ConfigurationQuery<A,B>,B extends ExecutableConfigurationQuery<A,B>,C extends ListConfigurationQuery<C>>

Type Parameters:
A - source specific query type
B - source specific executable query type
C - source specific list query type
All Known Subinterfaces:
ConfigurableConfigurationSource<A,B,C,D,E>, DefaultableConfigurationSource<A,B,C,D>
All Known Implementing Classes:
AbstractConfigurableConfigurationSource, AbstractConfigurationSource, AbstractHashConfigurationSource, AbstractPropertiesConfigurationSource, BootstrapConfigurationSource, CommandLineConfigurationSource, CompositeConfigurationSource, CPropsFileConfigurationSource, MapConfigurationSource, PropertiesConfigurationSource, PropertyFileConfigurationSource, RedisConfigurationSource, SystemEnvironmentConfigurationSource, SystemPropertiesConfigurationSource, VersionedRedisConfigurationSource

public interface ConfigurationSource<A extends ConfigurationQuery<A,B>,B extends ExecutableConfigurationQuery<A,B>,C extends ListConfigurationQuery<C>>

A configuration source gives access to configuration properties.

Configuration properties can be queries as follows:


 ConfigurationSource<?,?,?> source = ...

 Map<String, String> propertiesAsString = source
     .get("prop1", "prop2")
     .execute()
     .collect(Collectors.toMap(
             result -> result.getQueryKey().getName(),
             result -> result.getResult()
                 .flatMap(property -> property.asString()).orElse(null)
         )
     )
     .block();
 

Parameters can be specified on a query to specify the context for which values must be retrieved:


 Map<String, String> propertiesAsString = source
     .get("prop1", "prop2")
         .withParameters("environment", "test")
     .execute()
     .collect(Collectors.toMap(
             result -> result.getQueryKey().getName(),
             result -> result.getResult()
                 .flatMap(property -> property.asString()).orElse(null)
         )
     )
     .block();
 

Queries can be executed in a batch:


 Map<String, String> propertiesAsString = source
     .get("prop1", "prop2").and()
     .get("prop3", "prop4")
         .withParameters("customer", "abc")
     .execute()
     .collect(Collectors.toMap(
             result -> result.getQueryKey().getName(),
             result -> result.getResult()
                 .flatMap(property -> property.asString()).orElse(null)
         )
     )
     .block();
 
Since:
1.0
Author:
Jeremy Kuhn
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String... names)
    Creates a configuration query to retrieve the specified properties.
    list(String name)
    Creates a list configuration query to list configuration properties defined with the specified property name.
  • Method Details

    • get

      B get(String... names) throws IllegalArgumentException

      Creates a configuration query to retrieve the specified properties.

      Parameters:
      names - an array of property names
      Returns:
      an executable configuration query
      Throws:
      IllegalArgumentException - if the array of names is null or empty
    • list

      C list(String name) throws IllegalArgumentException

      Creates a list configuration query to list configuration properties defined with the specified property name.

      Parameters:
      name - a property name
      Returns:
      a list configuration query
      Throws:
      IllegalArgumentException - if the name is null or empty