Package oshi.util
Class GlobalConfig
java.lang.Object
oshi.util.GlobalConfig
@NotThreadSafe public final class GlobalConfig extends java.lang.Object
The global configuration utility. See
src/main/resources/oshi.properties
for default values.
This class is not thread safe if methods manipulating the configuration are used. These methods are intended for use by a single thread at startup, before instantiation of any other OSHI classes. OSHI does not guarantee re- reading of any configuration changes.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GlobalConfig.PropertyException
Indicates that a configuration value is invalid. -
Method Summary
Modifier and Type Method Description static void
clear()
Clear the configuration.static boolean
get(java.lang.String key, boolean def)
Get theboolean
property associated with the given key.static double
get(java.lang.String key, double def)
Get thedouble
property associated with the given key.static int
get(java.lang.String key, int def)
Get theint
property associated with the given key.static java.lang.String
get(java.lang.String key, java.lang.String def)
Get theString
property associated with the given key.static void
load(java.util.Properties properties)
Load the givenProperties
into the global configuration.static void
remove(java.lang.String key)
Reset the given property to its default value.static void
set(java.lang.String key, java.lang.Object val)
Set the given property, overwriting any existing value.
-
Method Details
-
get
public static java.lang.String get(java.lang.String key, java.lang.String def)Get theString
property associated with the given key.- Parameters:
key
- The property keydef
- The default value- Returns:
- The property value or the given default if not found
-
get
public static int get(java.lang.String key, int def)Get theint
property associated with the given key.- Parameters:
key
- The property keydef
- The default value- Returns:
- The property value or the given default if not found
-
get
public static double get(java.lang.String key, double def)Get thedouble
property associated with the given key.- Parameters:
key
- The property keydef
- The default value- Returns:
- The property value or the given default if not found
-
get
public static boolean get(java.lang.String key, boolean def)Get theboolean
property associated with the given key.- Parameters:
key
- The property keydef
- The default value- Returns:
- The property value or the given default if not found
-
set
public static void set(java.lang.String key, java.lang.Object val)Set the given property, overwriting any existing value. If the given value isnull
, the property is removed.- Parameters:
key
- The property keyval
- The new value
-
remove
public static void remove(java.lang.String key)Reset the given property to its default value.- Parameters:
key
- The property key
-
clear
public static void clear()Clear the configuration. -
load
public static void load(java.util.Properties properties)Load the givenProperties
into the global configuration.- Parameters:
properties
- The new properties
-