Interface SystemConfig

All Known Implementing Classes:
LayeredFileSystemConfig

public interface SystemConfig
SystemConfig is an interface for retrieving configuration values, allowing for implicit type conversion and use of a runtime properties interface to override configured settings.
  • Method Details

    • setProperty

      default void setProperty(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Sets property value for a key.
      Parameters:
      key - The key of the property to change
      value - The value to set to
      Throws:
      NullPointerException - if either key or value is null
    • resetProperty

      default void resetProperty(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Updates a property from the user-defined runtime configuration.
      Parameters:
      key - The key of the property to update
      value - The value to set to
      Throws:
      NullPointerException - if either key or value is null
    • clearProperty

      default void clearProperty(@NotNull @NotNull String key)
      Removes property from the use-defined runtime configuration.
      Parameters:
      key - The key of the property to remove
      Throws:
      NullPointerException - if key is null
    • getPackageVariableName

      @NotNull @NotNull String getPackageVariableName(@NotNull @NotNull String suffix)
      Gets a package scoped variable name.
      Parameters:
      suffix - The variable name of the configuration variable without the package prefix
      Returns:
      variable name
      Throws:
      NullPointerException - if suffix is null
    • getStringProperty

      @NotNull @NotNull Optional<String> getStringProperty(@NotNull @NotNull String key)
      Returns property value as String value wrapped inside an Optional for a key or empty if no such property exists.
      Parameters:
      key - The key for which value needs to be fetched
      Returns:
      an Optional value for the requested key or Optional.empty()
      Throws:
      NullPointerException - if key is null
    • getIntProperty

      @NotNull @NotNull Optional<Integer> getIntProperty(@NotNull @NotNull String key)
      Returns property value as int value wrapped inside an Optional for a key or empty if no such property exists.
      Parameters:
      key - The key for which value needs to be fetched
      Returns:
      an Optional value for the requested key or Optional.empty()
      Throws:
      NullPointerException - if key is null
    • getBooleanProperty

      @NotNull @NotNull Optional<Boolean> getBooleanProperty(@NotNull @NotNull String key)
      Returns property value as boolean value wrapped inside an Optional for a key or empty if no such property exists.
      Parameters:
      key - The key for which value needs to be fetched
      Returns:
      an Optional value for the requested key or Optional.empty()
      Throws:
      NullPointerException - if key is null
    • getLongProperty

      @NotNull @NotNull Optional<Long> getLongProperty(@NotNull @NotNull String key)
      Returns property value as long value wrapped inside an Optional for a key or empty if no such property exists.
      Parameters:
      key - The key for which value needs to be fetched
      Returns:
      an Optional value for the requested key or Optional.empty()
      Throws:
      NullPointerException - if key is null
    • getDoubleProperty

      @NotNull @NotNull Optional<Double> getDoubleProperty(@NotNull @NotNull String key)
      Returns property value as a double wrapped inside an Optional for a key or empty if no such property exists.
      Parameters:
      key - The key for which value needs to be fetched
      Returns:
      an Optional value for the requested key or Optional.empty()
      Throws:
      NullPointerException - if key is null
    • getFloatProperty

      @NotNull @NotNull Optional<Float> getFloatProperty(@NotNull @NotNull String key)
      Returns property value as float value wrapped inside an Optional for a key or empty if no such property exists.
      Parameters:
      key - The key for which value needs to be fetched
      Returns:
      an Optional value for the requested key or Optional.empty()
      Throws:
      NullPointerException - if key is null
    • getRuntimeProperties

      @NotNull @NotNull Properties getRuntimeProperties()
      Returns the properties used to hold the highest-priority config values.

      This method is intended primarily for interface support and not for client interactions

      Notes: this is a design flaw based on how it is used in method such as setProperty(String, String). If implementations produces a shallow copy of the runtime properties, then setProperty(String, String) will fail to accomplish what it supposed to do. The fact that this method is "not being called by client" pushes us to look at problem at a higher level: this method assumes the returned properties are directly mutable and will mutate the config instance directly. This violates encapsulation. we should remove this method and ask client to implement setProperty(String, String)

      Returns:
      a properties object which act as a runtime mask against other configuration properties