001/*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2013 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * SonarQube is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020package org.sonar.api;
021
022import java.lang.annotation.ElementType;
023import java.lang.annotation.Retention;
024import java.lang.annotation.RetentionPolicy;
025import java.lang.annotation.Target;
026
027/**
028 * Property value can be set in different ways :
029 * <ul>
030 * <li>System property</li>
031 * <li>Maven command-line (-Dfoo=bar)</li>
032 * <li>Maven pom.xml (element <properties>)</li>
033 * <li>Maven settings.xml</li>
034 * <li>Sonar web interface</li>
035 * </ul>
036 * <p/>
037 * Value is accessible in batch extensions via the Configuration object of class <code>org.sonar.api.resources.Project</code>
038 * (see method <code>getConfiguration()</code>).
039 * <p/>
040 * <p><strong>Must be used in <code>org.sonar.api.Plugin</code> classes only.</strong></p>
041 * <p></p>
042 * It's recommended to use the class {@link org.sonar.api.config.PropertyDefinition} since v3.6.
043 *
044 * @since 1.10
045 */
046@Retention(RetentionPolicy.RUNTIME)
047@Target(ElementType.TYPE)
048public @interface Property {
049
050  /**
051   * Unique key within all plugins. It's recommended to prefix the key by 'sonar.' and the plugin name. Examples :
052   * 'sonar.cobertura.reportPath' and 'sonar.cpd.minimumTokens'.
053   */
054  String key();
055
056  /**
057   * The empty string "" is considered as null, so it's not possible to have empty strings for default values.
058   */
059  String defaultValue() default "";
060
061  String name();
062
063  String description() default "";
064
065  /**
066   * @since 2.11
067   * @see org.sonar.api.config.PropertyDefinition#category()
068   */
069  String category() default "";
070
071  /**
072   * Is the property displayed in project settings page ?
073   */
074  boolean project() default false;
075
076  /**
077   * Is the property displayed in module settings page ? A module is a maven sub-project.
078   */
079  boolean module() default false;
080
081  /**
082   * Is the property displayed in global settings page ?
083   */
084  boolean global() default true;
085
086  /**
087   * @since 3.0
088   */
089  PropertyType type() default PropertyType.STRING;
090
091  /**
092   * Options for *_LIST types
093   *
094   * @since 3.0  Options for property of type PropertyType.SINGLE_SELECT_LIST</code>
095   * For example {"property_1", "property_3", "property_3"}).
096   *
097   * @since 3.3  Options for property of type PropertyType.METRIC</code>.
098   * If no option is specified, any metric will match.
099   * If options are specified, all must match for the metric to be displayed.
100   * Three types of filter are supported <code>key:REGEXP</code>, <code>domain:REGEXP</code> and <code>type:comma_separated__list_of_types</code>.
101   * For example <code>key:new_.*</code> will match any metric which key starts by <code>new_</code>.
102   * For example <code>type:INT,FLOAT</code> will match any metric of type <code>INT</code> or <code>FLOAT</code>.
103   * For example <code>type:NUMERIC</code> will match any metric of numerictype.
104   */
105  String[] options() default {};
106
107  /**
108   * Can the property take multiple values. Eg: list of email addresses.
109   *
110   * @since 3.3
111   */
112  boolean multiValues() default false;
113
114  /**
115   * A Property of type <code>PropertyType.PROPERTY_SET</code> can reference a set of properties
116   * by its key.
117   *
118   * @since 3.3
119   */
120  String propertySetKey() default "";
121
122  /**
123   * A Property with fields is considered a property set.
124   *
125   * @since 3.3
126   */
127  PropertyField[] fields() default {};
128
129  /**
130   * Relocation of key.
131   * @since 3.4
132   */
133  String deprecatedKey() default "";
134}