Class SystemSettingUtils


  • public final class SystemSettingUtils
    extends Object
    A set of static utility methods for shared code in SystemSetting.
    • Method Detail

      • resolveSetting

        public static Optional<String> resolveSetting​(SystemSetting setting)
        Resolve the value of this system setting, loading it from the System by checking:
        1. The system properties.
        2. The environment variables.
        3. The default value.
      • resolveNonDefaultSetting

        public static Optional<String> resolveNonDefaultSetting​(SystemSetting setting)
        Resolve the value of this system setting, loading it from the System by checking:
        1. The system properties.
        2. The environment variables.

        This is similar to resolveSetting(SystemSetting) but does not fall back to the default value if neither the environment variable or system property value are present.

      • resolveEnvironmentVariable

        public static Optional<String> resolveEnvironmentVariable​(SystemSetting setting)
        Attempt to load this setting from the environment variables.
      • resolveEnvironmentVariable

        public static Optional<String> resolveEnvironmentVariable​(String key)
        Attempt to load a key from the environment variables.
      • safeStringToBoolean

        public static Boolean safeStringToBoolean​(SystemSetting setting,
                                                  String value)
        Convert a string to boolean safely (as opposed to the less strict Boolean.parseBoolean(String)). If a customer specifies a boolean value it should be "true" or "false" (case insensitive) or an exception will be thrown.