本文整理了Java中org.sonar.api.config.Settings.getDefaultValue()
方法的一些代码示例,展示了Settings.getDefaultValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getDefaultValue()
方法的具体详情如下:
包路径:org.sonar.api.config.Settings
类名称:Settings
方法名:getDefaultValue
暂无
代码示例来源:origin: SonarSource/sonarqube
public boolean hasDefaultValue(String key) {
return StringUtils.isNotEmpty(getDefaultValue(key));
}
代码示例来源:origin: SonarSource/sonarqube
/**
* The effective value of the specified property. Can return
* {@code null} if the property is not set and has no
* defined default value.
* <p>
* If the property is encrypted with a secret key,
* then the returned value is decrypted.
* </p>
*
* @throws IllegalStateException if value is encrypted but fails to be decrypted.
*/
@CheckForNull
public String getString(String key) {
String effectiveKey = definitions.validKey(key);
Optional<String> value = getRawString(effectiveKey);
if (!value.isPresent()) {
// default values cannot be encrypted, so return value as-is.
return getDefaultValue(effectiveKey);
}
if (encryption.isEncrypted(value.get())) {
try {
return encryption.decrypt(value.get());
} catch (Exception e) {
throw new IllegalStateException("Fail to decrypt the property " + effectiveKey + ". Please check your secret key.", e);
}
}
return value.get();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void default_values_should_be_loaded_from_definitions() {
Settings settings = new MapSettings(definitions);
assertThat(settings.getDefaultValue("hello")).isEqualTo("world");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void test_get_default_value() {
Settings settings = new MapSettings(definitions);
assertThat(settings.getDefaultValue("unknown")).isNull();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldCreateByIntrospectingComponent() {
Settings settings = new MapSettings();
settings.getDefinitions().addComponent(MyComponent.class);
// property definition has been loaded, ie for default value
assertThat(settings.getDefaultValue("foo")).isEqualTo("bar");
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
public boolean hasDefaultValue(String key) {
return StringUtils.isNotEmpty(getDefaultValue(key));
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
public boolean hasDefaultValue(String key) {
return StringUtils.isNotEmpty(getDefaultValue(key));
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
/**
* Does not decrypt value.
*/
protected String getClearString(String key) {
doOnGetProperties(key);
String validKey = definitions.validKey(key);
String value = properties.get(validKey);
if (value == null) {
value = getDefaultValue(validKey);
}
return value;
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch
/**
* The public URL is optionally configured on server. If not, then the regular URL is returned.
* See https://jira.sonarsource.com/browse/SONAR-4239
*/
private String publicUrl() {
String baseUrl = settings.getString(CoreProperties.SERVER_BASE_URL);
if (baseUrl.equals(settings.getDefaultValue(CoreProperties.SERVER_BASE_URL))) {
// crap workaround for https://jira.sonarsource.com/browse/SONAR-7109
// If server base URL was not configured in Sonar server then is is better to take URL configured on batch side
baseUrl = wsClient.baseUrl();
}
return baseUrl.replaceAll("(/)+$", "");
}
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
@VisibleForTesting
void logSuccess(Logger logger) {
if (analysisMode.isPreview() || analysisMode.isMediumTest()) {
logger.info("ANALYSIS SUCCESSFUL");
} else {
String baseUrl = settings.getString(CoreProperties.SERVER_BASE_URL);
if (baseUrl.equals(settings.getDefaultValue(CoreProperties.SERVER_BASE_URL))) {
// If server base URL was not configured in Sonar server then is is better to take URL configured on batch side
baseUrl = serverClient.getURL();
}
if (!baseUrl.endsWith("/")) {
baseUrl += "/";
}
String url = baseUrl + "dashboard/index/" + project.getKey();
logger.info("ANALYSIS SUCCESSFUL, you can browse {}", url);
logger.info("Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.");
}
}
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
/**
* The effective value of the specified property. Can return
* {@code null} if the property is not set and has no
* defined default value.
* <p>
* If the property is encrypted with a secret key,
* then the returned value is decrypted.
* </p>
*
* @throws IllegalStateException if value is encrypted but fails to be decrypted.
*/
@CheckForNull
public String getString(String key) {
String effectiveKey = definitions.validKey(key);
Optional<String> value = getRawString(effectiveKey);
if (!value.isPresent()) {
// default values cannot be encrypted, so return value as-is.
return getDefaultValue(effectiveKey);
}
if (encryption.isEncrypted(value.get())) {
try {
return encryption.decrypt(value.get());
} catch (Exception e) {
throw new IllegalStateException("Fail to decrypt the property " + effectiveKey + ". Please check your secret key.", e);
}
}
return value.get();
}
内容来源于网络,如有侵权,请联系作者删除!