org.sonar.api.config.Settings.getDefinitions()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.sonar.api.config.Settings.getDefinitions()方法的一些代码示例,展示了Settings.getDefinitions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getDefinitions()方法的具体详情如下:
包路径:org.sonar.api.config.Settings
类名称:Settings
方法名:getDefinitions

Settings.getDefinitions介绍

[英]All the property definitions declared by core and plugins.
[中]核心和插件声明的所有属性定义。

代码示例

代码示例来源:origin: SonarSource/sonarqube

public ChildSettings(Settings parentSettings) {
 super(parentSettings.getDefinitions(), parentSettings.getEncryption());
 this.parentSettings = parentSettings;
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public ProtobufSystemInfo.Section toProtobuf() {
 ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
 protobuf.setName("Settings");
 PropertyDefinitions definitions = settings.getDefinitions();
 TreeMap<String, String> orderedProps = new TreeMap<>(settings.getProperties());
 for (Map.Entry<String, String> prop : orderedProps.entrySet()) {
  String key = prop.getKey();
  String value = obfuscateValue(definitions, key, prop.getValue());
  setAttribute(protobuf, key, value);
 }
 return protobuf.build();
}

代码示例来源: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.sonarsource.sonarqube/sonar-server

public ChildSettings(Settings parentSettings) {
 super(parentSettings.getDefinitions(), parentSettings.getEncryption());
 this.parentSettings = parentSettings;
}

代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api

public Settings setProperty(String key, @Nullable String[] values) {
 PropertyDefinition property = getDefinitions().get(key);
 if ((null == property) || (!property.multiValues())) {
  throw new IllegalStateException("Fail to set multiple values on a single value property " + key);
 }
 String text = null;
 if (values != null) {
  List<String> escaped = Lists.newArrayList();
  for (String value : values) {
   if (null != value) {
    escaped.add(value.replace(",", "%2C"));
   } else {
    escaped.add("");
   }
  }
  String escapedValue = Joiner.on(',').join(escaped);
  text = StringUtils.trim(escapedValue);
 }
 return setProperty(key, text);
}

代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api

/**
 * Value is split by comma and trimmed. Never returns null.
 * <p/>
 * Examples :
 * <ul>
 * <li>"one,two,three " -> ["one", "two", "three"]</li>
 * <li>"  one, two, three " -> ["one", "two", "three"]</li>
 * <li>"one, , three" -> ["one", "", "three"]</li>
 * </ul>
 */
public String[] getStringArray(String key) {
 PropertyDefinition property = getDefinitions().get(key);
 if ((null != property) && (property.multiValues())) {
  String value = getString(key);
  if (value == null) {
   return ArrayUtils.EMPTY_STRING_ARRAY;
  }
  List<String> values = Lists.newArrayList();
  for (String v : Splitter.on(",").trimResults().split(value)) {
   values.add(v.replace("%2C", ","));
  }
  return values.toArray(new String[values.size()]);
 }
 return getStringArrayBySeparator(key, ",");
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

@Override
public ProtobufSystemInfo.Section toProtobuf() {
 ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
 protobuf.setName("Settings");
 PropertyDefinitions definitions = settings.getDefinitions();
 TreeMap<String, String> orderedProps = new TreeMap<>(settings.getProperties());
 for (Map.Entry<String, String> prop : orderedProps.entrySet()) {
  String key = prop.getKey();
  String value = obfuscateValue(definitions, key, prop.getValue());
  setAttribute(protobuf, key, value);
 }
 return protobuf.build();
}

相关文章