Package oshi.util

Class GlobalConfig

java.lang.Object
oshi.util.GlobalConfig

@NotThreadSafe public final class GlobalConfig extends 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 
    Indicates that a configuration value is invalid.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Clear the configuration.
    static boolean
    get(String key, boolean def)
    Get the boolean property associated with the given key.
    static double
    get(String key, double def)
    Get the double property associated with the given key.
    static int
    get(String key, int def)
    Get the int property associated with the given key.
    static String
    get(String key, String def)
    Get the String property associated with the given key.
    static void
    load(Properties properties)
    Load the given Properties into the global configuration.
    static void
    Reset the given property to its default value.
    static void
    set(String key, Object val)
    Set the given property, overwriting any existing value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • get

      public static String get(String key, String def)
      Get the String property associated with the given key.
      Parameters:
      key - The property key
      def - The default value
      Returns:
      The property value or the given default if not found
    • get

      public static int get(String key, int def)
      Get the int property associated with the given key.
      Parameters:
      key - The property key
      def - The default value
      Returns:
      The property value or the given default if not found
    • get

      public static double get(String key, double def)
      Get the double property associated with the given key.
      Parameters:
      key - The property key
      def - The default value
      Returns:
      The property value or the given default if not found
    • get

      public static boolean get(String key, boolean def)
      Get the boolean property associated with the given key.
      Parameters:
      key - The property key
      def - The default value
      Returns:
      The property value or the given default if not found
    • set

      public static void set(String key, Object val)
      Set the given property, overwriting any existing value. If the given value is null, the property is removed.
      Parameters:
      key - The property key
      val - The new value
    • remove

      public static void remove(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(Properties properties)
      Load the given Properties into the global configuration.
      Parameters:
      properties - The new properties