/** * Return the value associated with the setting, or default value if no value is associated. * * @param setting a setting * @param defaultValue default value * @param <T> setting value type * @return the value associated with the setting */ public static <T> T valueOf(Setting<T> setting, T defaultValue) { return setting.value().orElse(defaultValue); }
/** * Return the value associated with the setting. * * @param setting a setting * @param <T> setting value type * @return the value associated with the setting * @throws com.hotels.styx.api.configuration.NoSystemPropertyDefined if there is no associated value */ public static <T> T valueOf(Setting<T> setting) { return setting.value().orElseThrow(() -> new NoSystemPropertyDefined(setting.name())); }