Class PropertyDefinition


  • @ScannerSide
    @ServerSide
    @ComputeEngineSide
    @SonarLintSide
    @ExtensionPoint
    public final class PropertyDefinition
    extends java.lang.Object
    Declare a plugin property. Values are available at runtime through the component Configuration.
    It's the programmatic alternative to the annotation Property. It is more testable and adds new features like sub-categories and ordering.
    Example:
    
       public class MyPlugin extends SonarPlugin {
         public List getExtensions() {
           return Arrays.asList(
             PropertyDefinition.builder("sonar.foo").name("Foo").build(),
             PropertyDefinition.builder("sonar.bar").name("Bar").defaultValue("123").type(PropertyType.INTEGER).build()
           );
         }
       }
     

    Keys in localization bundles are:
    • property.<key>.name is the label of the property
    • property.<key>.description is the optional description of the property
    • property.category.<category> is the category label
    • property.category.<category>.description is the category description
    • property.category.<category>.<subcategory> is the sub-category label
    • property.category.<category>.<subcategory>.description is the sub-category description
    Since:
    3.6
    • Method Detail

      • builder

        public static PropertyDefinition.Builder builder​(java.lang.String key)
        Parameters:
        key - the unique property key. If it ends with ".secured" then users need the administration permission to access the value.
      • key

        public java.lang.String key()
        Unique key within all plugins. It's recommended to prefix the key by 'sonar.' and the plugin name. Examples : 'sonar.cobertura.reportPath' and 'sonar.cpd.minimumTokens'.
      • defaultValue

        public java.lang.String defaultValue()
      • name

        public java.lang.String name()
      • options

        public java.util.List<java.lang.String> options()
        Options for *_LIST types
        Options for property of type PropertyType.SINGLE_SELECT_LIST.
        For example {"property_1", "property_3", "property_3"}).
      • description

        public java.lang.String description()
      • category

        public java.lang.String category()
        Category where the property appears in settings pages. By default equal to plugin name.
      • subCategory

        public java.lang.String subCategory()
        Sub-category where property appears in settings pages. By default sub-category is the category.
      • qualifiers

        public java.util.List<java.lang.String> qualifiers()
        Qualifiers that can display this property
      • global

        public boolean global()
        Is the property displayed in global settings page ?
      • multiValues

        public boolean multiValues()
      • deprecatedKey

        public java.lang.String deprecatedKey()
      • index

        public int index()
        Order to display properties in Sonar UI. When two properties have the same index then it is sorted by lexicographic order of property name.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object