Configurations
Overview
The Configurations class provides a set of methods to interact with the configuration settings using the platform. This API allows you to retrieve, modify, and manage configuration parameters for your application.
Methods
get
public static get(key: string, defaultValue?: string): string | undefinedRetrieve the value associated with the specified configuration key. If the key is not found, it returns the specified default value, or undefined if not provided.
Example
const value = Configurations.get("myConfigKey", "defaultValue");
console.log(value); // Output: "configuredValue" or "defaultValue" if not foundset
public static set(key: string, value: string): voidSet the value for the specified configuration key.
Example
Configurations.set("myConfigKey", "configuredValue");remove
public static remove(key: string): voidRemove the configuration entry associated with the specified key.
Example
Configurations.remove("myConfigKey");getKeys
public static getKeys(): string[]Retrieve an array of all configuration keys.
Example
const keys = Configurations.getKeys();
console.log(keys); // Output: ["key1", "key2", ...]load
public static load(path: string): voidLoad configuration settings from the specified path.
Example
Configurations.load("/path/to/config/file.properties");update
public static update(): voidUpdate the configuration settings.
Example
Configurations.update();getOS
public static getOS(): stringRetrieve the operating system name.
Example
const osName = Configurations.getOS();
console.log(osName); // Output: "Windows", "Mac OS X", "Linux", "Solaris", etc.isOSWindows
public static isOSWindows(): booleanCheck if the operating system is Windows.
Example
const isWindows = Configurations.isOSWindows();
console.log(isWindows); // Output: true or falseisOSMac
public static isOSMac(): booleanCheck if the operating system is Mac OS.
Example
const isMac = Configurations.isOSMac();
console.log(isMac); // Output: true or falseisOSUNIX
public static isOSUNIX(): booleanCheck if the operating system is UNIX-based.
Example
const isUNIX = Configurations.isOSUNIX();
console.log(isUNIX); // Output: true or falseisOSSolaris
public static isOSSolaris(): booleanCheck if the operating system is Solaris.
Example
const isSolaris = Configurations.isOSSolaris();
console.log(isSolaris); // Output: true or falseFunctions
| Function | Description | Returns |
|---|---|---|
| get(key, defaultValue)() | Returns the value for the specified key, or the default value | string |
| set(key, value) | Sets a value, for the specified key | - |
| getKeys() | Returns an arrays of keys | array of string |
| load(path) | Loads a configuration from a properties file at path | - |
| update() | Updates the loaded configurations | - |