Interface SettingSource

All Known Subinterfaces:
FunctionalSource, SettingStore
All Known Implementing Classes:
FunctionalStore, MapStore

public interface SettingSource
Interface for pluggable property sources used by Settings.

A setting source provides a way to retrieve property values. Sources are checked in reverse order (last added is checked first) when looking up properties.

For writable sources that support modifying property values, see SettingStore.

Return Value Semantics:
  • null - The setting does not exist in this source. The lookup will continue to the next source.
  • Optional.empty() - The setting exists but has an explicitly null value. This will be returned immediately, overriding any values from lower-priority sources.
  • Optional.of(value) - The setting exists and has a non-null value. This will be returned immediately.
Examples:

// Create a read-only functional source directly from a lambda FunctionalSource readOnly = name -> opt(System.getProperty(name)); // Or use the factory method FunctionalSource readOnly2 = FunctionalSource.of(System::getProperty); // Stores can be used as sources (they extend SettingSource) MapStore store = new MapStore(); store.set("my.property", "value"); Settings.get().addSource(store); // Stores can be added as sources

  • Method Summary

    Modifier and Type
    Method
    Description
    get(String name)
    Returns a setting in this setting source.
  • Method Details

    • get

      Returns a setting in this setting source.

      Return value semantics:

      • null - The setting does not exist in this source. The lookup will continue to the next source.
      • Optional.empty() - The setting exists but has an explicitly null value. This will be returned immediately, overriding any values from lower-priority sources.
      • Optional.of(value) - The setting exists and has a non-null value. This will be returned immediately.
      Parameters:
      name - The property name.
      Returns:
      The property value, null if the property doesn't exist in this source, or Optional.empty() if the property exists but has a null value.