Interface SettingsSource

All Known Subinterfaces:
AutomataLibSettingsSource
All Known Implementing Classes:
AbstractClassPathFileSource, AbstractSystemPropertiesSource, AutomataLibLocalPropertiesSource, AutomataLibPropertiesSource, AutomataLibSystemPropertiesSource, LocalFileSource
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SettingsSource
Utility interface to mark the source of a setting.
  • Method Details

    • readSettings

      static <S extends SettingsSource> Properties readSettings(ServiceLoader<S> loader)
      Convenience method for parsing properties from a SettingsSource. Note that this method requires an instantiated ServiceLoader instead of just the settings class, to support polymorphic SettingsSources in a JPMS environment. Otherwise, this module would have to declare a uses clause and only true SettingsSources could be read.
      Type Parameters:
      S - concrete SettingsSource type
      Parameters:
      loader - the service loader
      Returns:
      the filled properties after all loaded SettingsSources have been queried
    • readSettings

      static <S extends SettingsSource> void readSettings(ServiceLoader<S> loader, Properties p)
      Convenience method for readSettings(ServiceLoader) that directly writes to the given Properties object.
      Type Parameters:
      S - concrete SettingsSource type
      Parameters:
      loader - the service loader
      p - the properties object to write to
    • loadSettings

      void loadSettings(Properties props)
      Load the parsed settings into the given property object.
      Parameters:
      props - the object to write the settings to
    • getPriority

      default int getPriority()
      Returns the priority of this source. This is used to decide which source wins, if multiple sources write the same properties.
      Returns:
      the priority