|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sonar.api.config.Settings
public class Settings
Project settings on batch side, or global settings on server side. This component does not access to database, so property changed via setter methods are not persisted.
For testing, you can create a new empty Settings
component using Settings()
and then
populate it using all variant of setProperty
.
If you want to test with default values of your properties taken into account there are two ways dependening on how you declare your properties.
@Properties({
@Property(
key = "sonar.myProp",
defaultValue = "A default value",
name = "My property"),
})
public class MyPlugin extends SonarPlugin {
then you can use:
new Settings(new PropertyDefinitions(MyPlugin.class))
PropertyDefinition.builder(String)
way like:
public class MyPlugin extends SonarPlugin {
public List getExtensions() {
return Arrays.asList(
PropertyDefinition.builder("sonar.myProp").name("My property").defaultValue("A default value").build()
);
}
}
then you can use:
new Settings(new PropertyDefinitions(new MyPlugin().getExtensions()))
Field Summary | |
---|---|
protected PropertyDefinitions |
definitions
|
protected Map<String,String> |
properties
|
Constructor Summary | |
---|---|
Settings()
|
|
Settings(PropertyDefinitions definitions)
|
|
Settings(Settings other)
Clone settings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<String,String> properties
protected PropertyDefinitions definitions
Constructor Detail |
---|
public Settings()
public Settings(PropertyDefinitions definitions)
public Settings(Settings other)
Method Detail |
---|
public Encryption getEncryption()
public String getDefaultValue(String key)
public boolean hasKey(String key)
public boolean hasDefaultValue(String key)
public String getString(String key)
protected String getClearString(String key)
public boolean getBoolean(String key)
public int getInt(String key)
public long getLong(String key)
public Date getDate(String key)
public Date getDateTime(String key)
public Float getFloat(String key)
public Double getDouble(String key)
public String[] getStringArray(String key)
public String[] getStringLines(String key)
public String[] getStringArrayBySeparator(String key, String separator)
public List<String> getKeysStartingWith(String prefix)
public Settings appendProperty(String key, String value)
public Settings setProperty(String key, @Nullable String[] values)
public Settings setProperty(String key, @Nullable String value)
public Settings setProperty(String key, @Nullable Boolean value)
public Settings setProperty(String key, @Nullable Integer value)
public Settings setProperty(String key, @Nullable Long value)
public Settings setProperty(String key, @Nullable Double value)
public Settings setProperty(String key, @Nullable Float value)
public Settings setProperty(String key, @Nullable Date date)
public Settings addProperties(Map<String,String> props)
public Settings addProperties(Properties props)
@Deprecated public Settings addSystemProperties()
@Deprecated public Settings addEnvironmentVariables()
public Settings setProperties(Map<String,String> props)
public Settings setProperty(String key, @Nullable Date date, boolean includeTime)
public Settings removeProperty(String key)
public Settings clear()
public Map<String,String> getProperties()
public PropertyDefinitions getDefinitions()
public static Settings createForComponent(Object component)
protected void doOnSetProperty(String key, @Nullable String value)
protected void doOnRemoveProperty(String key)
protected void doOnClearProperties()
protected void doOnGetProperties(String key)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |