/** * Change a property value in a restricted scope only, depending on execution context. New value * is <b>never</b> persisted. New value is ephemeral and kept in memory only: * <ul> * <li>during current analysis in the case of scanner stack</li> * <li>during processing of current HTTP request in the case of web server stack</li> * <li>during execution of current task in the case of Compute Engine stack</li> * </ul> * * Property is temporarily removed if the parameter {@code value} is {@code null} */ public Settings setProperty(String key, @Nullable String value) { String validKey = definitions.validKey(key); if (value == null) { removeProperty(validKey); } else { set(validKey, trim(value)); } return this; }
/** * @see #setProperty(String, String) */ public Settings setProperty(String key, @Nullable Date date, boolean includeTime) { if (date == null) { return removeProperty(key); } return setProperty(key, includeTime ? DateUtils.formatDateTime(date) : DateUtils.formatDate(date)); }
@Test public void publicRootUrl() { Settings settings = new MapSettings(); ScannerWsClient client = mock(ScannerWsClient.class); when(client.baseUrl()).thenReturn("http://foo.com/"); DefaultServer metadata = new DefaultServer(((MapSettings) settings).asConfig(), client, null); settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://server.com/"); assertThat(metadata.getPublicRootUrl()).isEqualTo("http://server.com"); settings.removeProperty(CoreProperties.SERVER_BASE_URL); assertThat(metadata.getPublicRootUrl()).isEqualTo("http://foo.com"); }
public Settings setProperty(String key, @Nullable Date date, boolean includeTime) { if (date == null) { return removeProperty(key); } return setProperty(key, includeTime ? DateUtils.formatDateTime(date) : DateUtils.formatDate(date)); }
/** * @see #setProperty(String, String) */ public Settings setProperty(String key, @Nullable Date date, boolean includeTime) { if (date == null) { return removeProperty(key); } return setProperty(key, includeTime ? DateUtils.formatDateTime(date) : DateUtils.formatDate(date)); }
/** * Change a property value in a restricted scope only, depending on execution context. New value * is <b>never</b> persisted. New value is ephemeral and kept in memory only: * <ul> * <li>during current analysis in the case of scanner stack</li> * <li>during processing of current HTTP request in the case of web server stack</li> * <li>during execution of current task in the case of Compute Engine stack</li> * </ul> * * Property is temporarily removed if the parameter {@code value} is {@code null} */ public Settings setProperty(String key, @Nullable String value) { String validKey = definitions.validKey(key); if (value == null) { removeProperty(validKey); } else { set(validKey, trim(value)); } return this; }