Class MapConfigSource

All Implemented Interfaces:
ConfigSource, NodeConfigSource, PollableSource<Map<?,?>>, Source, Supplier<ConfigSource>
Direct Known Subclasses:
ConfigSources.SystemPropertiesConfigSource

public class MapConfigSource extends AbstractConfigSource implements ConfigSource, NodeConfigSource, PollableSource<Map<?,?>>
ConfigSource implementation based on Map<String, String>.

Map key format must conform to Config key format.

See Also:
  • Method Details

    • builder

      public static MapConfigSource.Builder builder()
      Create a new fluent API builder.
      Returns:
      a new builder instance
    • create

      public static MapConfigSource create(Map<String,String> map)
      Create a new config source from the provided map.
      Parameters:
      map - config properties
      Returns:
      a new map config source
    • create

      public static MapConfigSource create(Properties properties)
      Create a new config source from the provided properties.
      Parameters:
      properties - properties to serve as source of data
      Returns:
      a new map config source
    • isModified

      public boolean isModified(Map<?,?> stamp)
      Description copied from interface: PollableSource
      This method is invoked to check if this source has changed.
      Specified by:
      isModified in interface PollableSource<Map<?,?>>
      Parameters:
      stamp - the stamp of the last loaded content
      Returns:
      true if the current data of this config source differ from the loaded data, including cases when the source has disappeared
    • pollingStrategy

      public Optional<PollingStrategy> pollingStrategy()
      Description copied from class: AbstractSource
      A polling strategy of this source, if it implements PollableSource and has one configured.
      Specified by:
      pollingStrategy in interface PollableSource<Map<?,?>>
      Overrides:
      pollingStrategy in class AbstractSource
      Returns:
      polling strategy if any configured
    • load

      Description copied from interface: NodeConfigSource
      Loads the underlying source data. This method is only called when the source Source.exists().

      The method can be invoked repeatedly, for example during retries.

      Specified by:
      load in interface NodeConfigSource
      Returns:
      An instance of T as read from the underlying origin of the data (if it exists)
      Throws:
      ConfigException - in case of errors loading from the underlying origin
    • uid

      protected String uid()
      Description copied from class: AbstractSource
      Returns universal id of source to be used to construct AbstractSource.description().
      Overrides:
      uid in class AbstractSource
      Returns:
      universal id of source