@Override public Optional<T> loadService() { return implSetting .getStringValue() .map(this::createServiceFromProperty); }
/** * Attempt to load a system setting from {@link System#getProperty(String)} and {@link System#getenv(String)}. This should be * used in favor of those methods because the SDK should support both methods of configuration. * * The result will be converted to a boolean. * * {@link System#getProperty(String)} takes precedent over {@link System#getenv(String)} if both are specified. * * @return The requested setting, or {@link Optional#empty()} if the values were not set, or the security manager did not * allow reading the setting. */ default Optional<Boolean> getBooleanValue() { return getStringValue().map(value -> SystemSettingUtils.safeStringToBoolean(this, value)); }
/** * Attempt to load a system setting from {@link System#getProperty(String)} and {@link System#getenv(String)}. This should be * used in favor of those methods because the SDK should support both methods of configuration. * * The result will be converted to a boolean. * * {@link System#getProperty(String)} takes precedent over {@link System#getenv(String)} if both are specified. * * @return The requested setting, or {@link Optional#empty()} if the values were not set, or the security manager did not * allow reading the setting. */ default Optional<Boolean> getBooleanValue() { return getStringValue().map(value -> SystemSettingUtils.safeStringToBoolean(this, value)); }
/** * Load the requested system setting as per the documentation in {@link #getStringValue()}, throwing an exception if the value * was not set and had no default. * * @return The requested setting. */ default String getStringValueOrThrow() { return getStringValue().orElseThrow(() -> new IllegalStateException("Either the environment variable " + environmentVariable() + " or the java" + "property " + property() + " must be set.")); }
/** * Load the requested system setting as per the documentation in {@link #getStringValue()}, throwing an exception if the value * was not set and had no default. * * @return The requested setting. */ default String getStringValueOrThrow() { return getStringValue().orElseThrow(() -> new IllegalStateException("Either the environment variable " + environmentVariable() + " or the java" + "property " + property() + " must be set.")); }