Package io.github.qubitpi.athena.config
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 Summary
Modifier and TypeMethodDescriptiondefault void
clearProperty
(@NotNull String key) Removes property from the use-defined runtime configuration.getBooleanProperty
(@NotNull String key) getDoubleProperty
(@NotNull String key) getFloatProperty
(@NotNull String key) getIntProperty
(@NotNull String key) getLongProperty
(@NotNull String key) @NotNull String
getPackageVariableName
(@NotNull String suffix) Gets a package scoped variable name.@NotNull Properties
Returns the properties used to hold the highest-priority config values.getStringProperty
(@NotNull String key) default void
resetProperty
(@NotNull String key, @NotNull String value) Updates a property from the user-defined runtime configuration.default void
setProperty
(@NotNull String key, @NotNull String value) Sets property value for a key.
-
Method Details
-
setProperty
Sets property value for a key.- Parameters:
key
- The key of the property to changevalue
- The value to set to- Throws:
NullPointerException
- if eitherkey
orvalue
isnull
-
resetProperty
Updates a property from the user-defined runtime configuration.- Parameters:
key
- The key of the property to updatevalue
- The value to set to- Throws:
NullPointerException
- if eitherkey
orvalue
isnull
-
clearProperty
Removes property from the use-defined runtime configuration.- Parameters:
key
- The key of the property to remove- Throws:
NullPointerException
- ifkey
isnull
-
getPackageVariableName
Gets a package scoped variable name.- Parameters:
suffix
- The variable name of the configuration variable without the package prefix- Returns:
- variable name
- Throws:
NullPointerException
- ifsuffix
isnull
-
getStringProperty
Returns property value as String value wrapped inside anOptional
for a key orempty
if no such property exists.- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
- Throws:
NullPointerException
- ifkey
isnull
-
getIntProperty
Returns property value as int value wrapped inside anOptional
for a key orempty
if no such property exists.- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
- Throws:
NullPointerException
- ifkey
isnull
-
getBooleanProperty
Returns property value as boolean value wrapped inside anOptional
for a key orempty
if no such property exists.- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
- Throws:
NullPointerException
- ifkey
isnull
-
getLongProperty
Returns property value as long value wrapped inside anOptional
for a key orempty
if no such property exists.- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
- Throws:
NullPointerException
- ifkey
isnull
-
getDoubleProperty
Returns property value as a double wrapped inside anOptional
for a key orempty
if no such property exists.- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
- Throws:
NullPointerException
- ifkey
isnull
-
getFloatProperty
Returns property value as float value wrapped inside anOptional
for a key orempty
if no such property exists.- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
- Throws:
NullPointerException
- ifkey
isnull
-
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, thensetProperty(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 implementsetProperty(String, String)
- Returns:
- a properties object which act as a runtime mask against other configuration properties
-