Class LayeredFileSystemConfig
- All Implemented Interfaces:
SystemConfig
LayeredFileSystemConfig
uses a layered model with the highest priority granted to runtime variable
modifications, followed by environment variables. It also uses a Property resource to allow runtime override of
configured behavior.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clearProperty
(String key) Removes property from the use-defined runtime configuration.getBooleanProperty
(String key) getDoubleProperty
(String key) getFloatProperty
(String key) getIntProperty
(String key) getLongProperty
(String key) getPackageVariableName
(String suffix) Gets a package scoped variable name.Returns the properties used to hold the highest-priority config values.getStringProperty
(String key) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.qubitpi.athena.config.SystemConfig
resetProperty, setProperty
-
Constructor Details
-
LayeredFileSystemConfig
public LayeredFileSystemConfig()Constructor.- Throws:
IllegalStateException
- if loading an existinguserConfig.properties
file fails
-
-
Method Details
-
getPackageVariableName
Description copied from interface:SystemConfig
Gets a package scoped variable name.- Specified by:
getPackageVariableName
in interfaceSystemConfig
- Parameters:
suffix
- The variable name of the configuration variable without the package prefix- Returns:
- variable name
-
getStringProperty
Description copied from interface:SystemConfig
Returns property value as String value wrapped inside anOptional
for a key orempty
if no such property exists.- Specified by:
getStringProperty
in interfaceSystemConfig
- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
-
getIntProperty
Description copied from interface:SystemConfig
Returns property value as int value wrapped inside anOptional
for a key orempty
if no such property exists.- Specified by:
getIntProperty
in interfaceSystemConfig
- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
-
getBooleanProperty
Description copied from interface:SystemConfig
Returns property value as boolean value wrapped inside anOptional
for a key orempty
if no such property exists.- Specified by:
getBooleanProperty
in interfaceSystemConfig
- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
-
getLongProperty
Description copied from interface:SystemConfig
Returns property value as long value wrapped inside anOptional
for a key orempty
if no such property exists.- Specified by:
getLongProperty
in interfaceSystemConfig
- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
-
getDoubleProperty
Description copied from interface:SystemConfig
Returns property value as a double wrapped inside anOptional
for a key orempty
if no such property exists.- Specified by:
getDoubleProperty
in interfaceSystemConfig
- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
-
getFloatProperty
Description copied from interface:SystemConfig
Returns property value as float value wrapped inside anOptional
for a key orempty
if no such property exists.- Specified by:
getFloatProperty
in interfaceSystemConfig
- Parameters:
key
- The key for which value needs to be fetched- Returns:
- an
Optional
value for the requested key orOptional.empty()
-
getRuntimeProperties
Description copied from interface:SystemConfig
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
SystemConfig.setProperty(String, String)
. If implementations produces a shallow copy of the runtime properties, thenSystemConfig.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 implementSystemConfig.setProperty(String, String)
- Specified by:
getRuntimeProperties
in interfaceSystemConfig
- Returns:
- a properties object which act as a runtime mask against other configuration properties
-
clearProperty
Description copied from interface:SystemConfig
Removes property from the use-defined runtime configuration.- Specified by:
clearProperty
in interfaceSystemConfig
- Parameters:
key
- The key of the property to remove
-