save()
the object gets saved to C:/Sateda/settings.dat
. When calling the constructor, an instance with default values gets generated and saved.
@author SebastianThis a type-enabled wrapper for a Properties object
Settings
object holds the properties used for external parameter overrides. Similar to java.util.Properties but: - supports UTF-8 (so \\uXXXX escapes are not needed or supported) - keys must be valid Java identifiers (actually must not contain '=' ':' '}' or white-space) - reverses priority in that duplicate entries are ignored, i.e. once set values cannot be changed - multiple files can be loaded - values can contain references to other values, e.g. name = .... ${key} .... - arrays are represented as strings, e.g. '[elem1,elem2]', and can span multiple lines - '\' can be used in values to escape '$' '{' '[' ',' ']'
@author burn
Using {@link ImmutableSettings#settingsBuilder()} in order to create a builderwhich in turn can create an immutable implementation of settings. @author kimchy (shay.banon) @see ImmutableSettings
This class aggregates mutable values which have life cycle of a certain operation or sequence of operations defined by the enclosing thread. @see ThreadLocal @author Richard Gomes
For testing, you can create a new empty {@link Settings} component using {@link #Settings()} and thenpopulate it using all variant of {@code 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.
{@literal @}Properties({ {@literal @}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))
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()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|